{"id":13795986,"url":"https://github.com/fluttercommunity/persist_theme","last_synced_at":"2025-07-14T21:33:50.397Z","repository":{"id":54196523,"uuid":"188468507","full_name":"fluttercommunity/persist_theme","owner":"fluttercommunity","description":"Persist Theme - A flutter plugin for persisting the theme data. Support for Dark Modes. Maintainer @rodydavis","archived":false,"fork":false,"pushed_at":"2021-09-27T18:18:32.000Z","size":5048,"stargazers_count":68,"open_issues_count":8,"forks_count":12,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-14T01:01:35.458Z","etag":null,"topics":["dark-theme","flutter","material-design","persist-theme","theme"],"latest_commit_sha":null,"homepage":"https://fluttercommunity.github.io/persist_theme/","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fluttercommunity.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-24T18:19:06.000Z","updated_at":"2025-03-05T00:37:48.000Z","dependencies_parsed_at":"2022-08-13T09:00:24.640Z","dependency_job_id":null,"html_url":"https://github.com/fluttercommunity/persist_theme","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fluttercommunity/persist_theme","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluttercommunity%2Fpersist_theme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluttercommunity%2Fpersist_theme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluttercommunity%2Fpersist_theme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluttercommunity%2Fpersist_theme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fluttercommunity","download_url":"https://codeload.github.com/fluttercommunity/persist_theme/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluttercommunity%2Fpersist_theme/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265352370,"owners_count":23751906,"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":["dark-theme","flutter","material-design","persist-theme","theme"],"created_at":"2024-08-03T23:01:04.885Z","updated_at":"2025-07-14T21:33:49.981Z","avatar_url":"https://github.com/fluttercommunity.png","language":"Dart","readme":"[![Flutter Community: persist_theme](https://fluttercommunity.dev/_github/header/persist_theme)](https://github.com/fluttercommunity/community)\n\n[![Buy Me A Coffee](https://img.shields.io/badge/Donate-Buy%20Me%20A%20Coffee-yellow.svg)](https://www.buymeacoffee.com/rodydavis)\n[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=WSH3GVC49GNNJ)\n![github pages](https://github.com/fluttercommunity/persist_theme/workflows/github%20pages/badge.svg)\n\n# persist_theme\n\nA Flutter plugin for persisting and dynamically changing the theme.\n\nOnline Demo: https://fluttercommunity.github.io/persist_theme/\n\n``` dart \nimport 'package:flutter/material.dart';\n\nimport 'package:persist_theme/persist_theme.dart';\nimport 'package:provider/provider.dart';\nimport 'package:scoped_model/scoped_model.dart';\n\nimport 'dart:io' show Platform;\nimport 'package:flutter/foundation.dart';\n\n/// main is entry point of Flutter application\nvoid main() {\n  // Desktop platforms aren't a valid platform.\n  _setTargetPlatformForDesktop();\n\n  return runApp(MyApp());\n}\n\n/// If the current platform is desktop, override the default platform to\n/// a supported platform (iOS for macOS, Android for Linux and Windows).\n/// Otherwise, do nothing.\nvoid _setTargetPlatformForDesktop() {\n  TargetPlatform targetPlatform;\n  if (Platform.isMacOS) {\n    targetPlatform = TargetPlatform.iOS;\n  } else if (Platform.isLinux || Platform.isWindows) {\n    targetPlatform = TargetPlatform.android;\n  }\n  if (targetPlatform != null) {\n    debugDefaultTargetPlatformOverride = targetPlatform;\n  }\n}\n\nfinal _model = ThemeModel();\n\nclass MyApp extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return ListenableProvider\u003cThemeModel\u003e(\n      create: (_) =\u003e _model..init(),\n      child: Consumer\u003cThemeModel\u003e(\n        builder: (context, model, child) {\n          return MaterialApp(\n            theme: model.theme,\n            home: HomeScreen(),\n          );\n        },\n      ),\n    );\n  }\n}\n\nclass HomeScreen extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    final _theme = Provider.of\u003cThemeModel\u003e(context);\n    return Scaffold(\n      appBar: AppBar(\n        title: const Text('Persist Theme'),\n      ),\n      body: ListView(\n        children: MediaQuery.of(context).size.width \u003e= 480\n            ? \u003cWidget\u003e[\n                Flex(\n                  direction: Axis.horizontal,\n                  children: \u003cWidget\u003e[\n                    Flexible(child: DarkModeSwitch()),\n                    Flexible(child: TrueBlackSwitch()),\n                  ],\n                ),\n                CustomThemeSwitch(),\n                Flex(\n                  direction: Axis.horizontal,\n                  children: \u003cWidget\u003e[\n                    Flexible(child: PrimaryColorPicker()),\n                    Flexible(child: AccentColorPicker()),\n                  ],\n                ),\n                DarkAccentColorPicker(),\n              ]\n            : \u003cWidget\u003e[\n                DarkModeSwitch(),\n                TrueBlackSwitch(),\n                CustomThemeSwitch(),\n                PrimaryColorPicker(),\n                AccentColorPicker(),\n                DarkAccentColorPicker(),\n              ],\n      ),\n      floatingActionButton: FloatingActionButton(\n        backgroundColor: _theme.accentColor,\n        child: Icon(Icons.add),\n        onPressed: () {},\n      ),\n    );\n  }\n}\n\n\n```\n\n## Customization\n\n* There are widgets provided but can be fully customized.\n* By default hide elements based on the theme.\n* The only requirement is that the material app is wrapped in a scoped model like shown above.\n\n## Screenshots\n\n\u003cimg src=\"https://github.com/fluttercommunity/persist_theme/blob/master/screenshots/1.png\" width=\"19%\"\u003e \u003cimg src=\"https://github.com/fluttercommunity/persist_theme/blob/master/screenshots/2.png\" width=\"19%\"\u003e \u003cimg src=\"https://github.com/fluttercommunity/persist_theme/blob/master/screenshots/3.png\" width=\"19%\"\u003e \u003cimg src=\"https://github.com/fluttercommunity/persist_theme/blob/master/screenshots/4.png\" width=\"19%\"\u003e \u003cimg src=\"https://github.com/fluttercommunity/persist_theme/blob/master/screenshots/5.png\" width=\"19%\"\u003e\n","funding_links":["https://www.buymeacoffee.com/rodydavis","https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=WSH3GVC49GNNJ"],"categories":["Libraries"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluttercommunity%2Fpersist_theme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffluttercommunity%2Fpersist_theme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluttercommunity%2Fpersist_theme/lists"}