{"id":21196338,"url":"https://github.com/davigmacode/flutter_theme_patrol","last_synced_at":"2025-08-22T12:33:04.093Z","repository":{"id":59150032,"uuid":"309569367","full_name":"davigmacode/flutter_theme_patrol","owner":"davigmacode","description":"Keep an eyes on your app theme changes.","archived":false,"fork":false,"pushed_at":"2024-06-27T04:17:17.000Z","size":8826,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-27T05:54:12.284Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/theme_patrol","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davigmacode.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["davigmacode"],"patreon":null,"open_collective":null,"ko_fi":"davigmacode","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":["https://www.buymeacoffee.com/davigmacode"]}},"created_at":"2020-11-03T04:08:44.000Z","updated_at":"2024-06-27T04:17:20.000Z","dependencies_parsed_at":"2024-03-17T05:26:28.288Z","dependency_job_id":"9c40bbe9-8319-4224-bad6-75403e964139","html_url":"https://github.com/davigmacode/flutter_theme_patrol","commit_stats":{"total_commits":25,"total_committers":1,"mean_commits":25.0,"dds":0.0,"last_synced_commit":"dace37c0224970f2e42d685a1c03916c6c41d0e0"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davigmacode%2Fflutter_theme_patrol","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davigmacode%2Fflutter_theme_patrol/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davigmacode%2Fflutter_theme_patrol/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davigmacode%2Fflutter_theme_patrol/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davigmacode","download_url":"https://codeload.github.com/davigmacode/flutter_theme_patrol/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225619790,"owners_count":17497724,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T19:35:37.352Z","updated_at":"2024-11-20T19:35:38.070Z","avatar_url":"https://github.com/davigmacode.png","language":"Dart","funding_links":["https://github.com/sponsors/davigmacode","https://ko-fi.com/davigmacode","https://www.buymeacoffee.com/davigmacode"],"categories":[],"sub_categories":[],"readme":"[![Pub Version](https://img.shields.io/pub/v/theme_patrol)](https://pub.dev/packages/theme_patrol) ![GitHub](https://img.shields.io/github/license/davigmacode/flutter_theme_patrol) [![GitHub](https://badgen.net/badge/icon/buymeacoffee?icon=buymeacoffee\u0026color=yellow\u0026label)](https://www.buymeacoffee.com/davigmacode) [![GitHub](https://badgen.net/badge/icon/ko-fi?icon=kofi\u0026color=red\u0026label)](https://ko-fi.com/davigmacode)\n\nKeep an eyes on your app theme changes, comes with a powerful set of tools to manage multiple themes with or without theme mode.\n\n[![Preview](https://github.com/davigmacode/flutter_theme_patrol/raw/master/media/preview.gif)](https://davigmacode.github.io/flutter_theme_patrol)\n\n[Demo](https://davigmacode.github.io/flutter_theme_patrol)\n\n## Features\n\n* Switch between light/dark mode\n* Switch between multiple themes\n* Override current theme color\n\n## Usage\n\nTo read more about classes and other references used by `theme_patrol`, see the [API Reference](https://pub.dev/documentation/theme_patrol/latest/).\n\n### Basic usage\n```dart\n// configuring\nThemePatrol(\n  initialMode: ThemeMode.system,\n  light: ThemeData(\n    brightness: Brightness.light,\n    colorSchemeSeed: Colors.purple,\n  ),\n  dark: ThemeData(\n    brightness: Brightness.dark,\n    colorSchemeSeed: Colors.purple,\n    toggleableActiveColor: Colors.purple,\n  ),\n  builder: (context, theme, child) {\n    return MaterialApp(\n      title: 'ThemePatrol',\n      theme: theme.data, // or theme.lightData\n      darkTheme: theme.darkData,\n      themeMode: theme.mode,\n      home: HomePage(),\n    );\n  },\n);\n\n// consuming\nThemeController theme = ThemePatrol.of(context);\nThemeController theme = ThemeProvider.of(context);\nThemeConsumer(\n  builder: (context, theme, child) {\n    return Container();\n  },\n);\n```\n\n### Verbose usage\n```dart\n// configuring\nThemeProvider(\n  controller: ThemeController(\n    initialMode: ThemeMode.system,\n    light: ThemeData(\n      brightness: Brightness.light,\n      colorSchemeSeed: Colors.purple,\n    ),\n    ...\n  ),\n  child: ThemeConsumer(\n    builder: (context, theme, child) {\n      return MaterialApp(\n        title: 'ThemePatrol',\n        theme: theme.data, // or theme.lightData\n        darkTheme: theme.darkData,\n        themeMode: theme.mode,\n        home: HomePage(),\n      );\n    },\n  ),\n);\n\n// consuming\nThemeController theme = ThemeProvider.of(context);\nThemeConsumer(\n  builder: (context, theme, child) {\n    return child;\n  },\n  child: Container(),\n);\n```\n\n### [Provider](https://pub.dev/packages/provider) usage\nTo read more about classes and other references used by `provider`, see their [API Reference](https://pub.dev/documentation/provider/latest/).\n```dart\n// configuring\nChangeNotifierProvider(\n  create: (_) =\u003e ThemeController(\n    initialMode: ThemeMode.system,\n    ...\n  ),\n  child: ...\n);\n\n// consuming\nThemeController theme = Provider.of\u003cThemeController\u003e(context, listen: true|false);\nThemeController theme = context.watch\u003cThemeController\u003e();\nThemeController theme = context.read\u003cThemeController\u003e();\nThemeMode mode = context.select((ThemeController theme) =\u003e theme.mode);\nConsumer\u003cThemeController\u003e(\n  builder: (_, theme, child) {\n    return Foo();\n  },\n  child: Baz(),\n);\n```\n\n## Use Case\n\n### Only switch between light/dark mode\n\n```dart\nThemePatrol(\n  initialMode: ThemeMode.system,\n  light: ThemeData(\n    brightness: Brightness.light,\n    colorSchemeSeed: Colors.purple,\n  ),\n  dark: ThemeData(\n    brightness: Brightness.dark,\n    colorSchemeSeed: Colors.purple,\n    toggleableActiveColor: Colors.purple,\n  ),\n  builder: (context, theme, child) {\n    return MaterialApp(\n      title: 'ThemePatrol',\n      theme: theme.data, // or theme.lightData\n      darkTheme: theme.darkData,\n      themeMode: theme.mode,\n      home: Scaffold(\n        appBar: AppBar(\n          title: Text(ThemePatrol.of(context).mode.toString()),\n          actions: [\n            ThemeConsumer(\n              builder: (context, theme, child) {\n                return Switch(\n                  value: theme.isDarkMode,\n                  onChanged: (selected) {\n                    if (selected) {\n                      theme.toDarkMode();\n                    } else {\n                      theme.toLightMode();\n                    }\n                  },\n                );\n              },\n            ),\n          ],\n        ),\n      ),\n    );\n  },\n);\n```\n\n### Multiple theme without dark mode\n\n```dart\nThemePatrol(\n  initialTheme: 'amber',\n  themes: {\n    'purple': ThemeConfig.fromColor(Colors.purple),\n    'pink': ThemeConfig.fromColor(Colors.pink),\n    'amber': ThemeConfig.fromColor(Colors.amber),\n    'elegant': ThemeConfig(data: ThemeData()),\n  },\n  builder: (context, theme, child) {\n    return MaterialApp(\n      title: 'ThemePatrol',\n      theme: theme.data, // or theme.lightData\n      home: Scaffold(\n        appBar: AppBar(\n          title: Text(ThemePatrol.of(context).selected),\n        ),\n        body: Center(\n          child: Column(\n            mainAxisAlignment: MainAxisAlignment.center,\n            children: \u003cWidget\u003e[\n              ThemeConsumer(\n                builder: (context, theme, _) {\n                  return Wrap(\n                    spacing: 5,\n                    children: theme.availableEntries\n                        .map((e) =\u003e ActionChip(\n                              label: Text(e.key),\n                              onPressed: () =\u003e theme.select(e.key),\n                              avatar: CircleAvatar(\n                                backgroundColor:\n                                    e.value.colorSchemeOf(context).primary,\n                              ),\n                            ))\n                        .toList(),\n                  );\n                },\n              ),\n            ],\n          ),\n        ),\n      ),\n    );\n  },\n);\n```\n\n### Multiple theme with dark mode\n\n```dart\nThemePatrol(\n  initialTheme: 'amber',\n  initialMode: ThemeMode.system,\n  themes: {\n    'purple': ThemeConfig.fromColor(Colors.purple),\n    'pink': ThemeConfig.fromColor(Colors.pink),\n    'amber': ThemeConfig.fromColor(Colors.amber),\n    'basic': ThemeConfig(data: ThemeData()),\n    'pro': ThemeConfig(data: ThemeData(), dark: ThemeData()),\n    'premium': ThemeConfig(light: ThemeData(), dark: ThemeData()),\n  },\n  builder: (context, theme, _) {\n    return MaterialApp(\n      title: 'ThemePatrol',\n      theme: theme.data, // or theme.lightData\n      darkTheme: theme.darkData,\n      themeMode: theme.mode,\n      home: Scaffold(\n        appBar: AppBar(\n          title: Text(ThemePatrol.of(context).selected),\n          actions: [\n            ThemeConsumer(\n              builder: (context, theme, _) {\n                return Switch(\n                  value: theme.isDarkMode,\n                  onChanged: (selected) {\n                    if (selected) {\n                      theme.toDarkMode();\n                    } else {\n                      theme.toLightMode();\n                    }\n                  },\n                );\n              },\n            ),\n          ],\n        ),\n        body: Center(\n          child: Column(\n            mainAxisAlignment: MainAxisAlignment.center,\n            children: \u003cWidget\u003e[\n              ThemeConsumer(\n                builder: (context, theme, _) {\n                  return Wrap(\n                    spacing: 5,\n                    children: theme.available.entries\n                        .map((e) =\u003e ActionChip(\n                              label: Text(e.key),\n                              onPressed: () =\u003e theme.select(e.key),\n                              avatar: CircleAvatar(\n                                backgroundColor:\n                                    e.value.colorSchemeOf(context).primary,\n                              ),\n                            ))\n                        .toList(),\n                  );\n                },\n              ),\n            ],\n          ),\n        ),\n      ),\n    );\n  },\n);\n```\n\n## Sponsoring\n\n\u003ca href=\"https://www.buymeacoffee.com/davigmacode\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" height=\"45\"\u003e\u003c/a\u003e\n\u003ca href=\"https://ko-fi.com/davigmacode\" target=\"_blank\"\u003e\u003cimg src=\"https://storage.ko-fi.com/cdn/brandasset/kofi_s_tag_white.png\" alt=\"Ko-Fi\" height=\"45\"\u003e\u003c/a\u003e\n\nIf this package or any other package I created is helping you, please consider to sponsor me so that I can take time to read the issues, fix bugs, merge pull requests and add features to these packages.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavigmacode%2Fflutter_theme_patrol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavigmacode%2Fflutter_theme_patrol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavigmacode%2Fflutter_theme_patrol/lists"}