{"id":24562871,"url":"https://github.com/kmartins/app_theme_mode","last_synced_at":"2025-03-16T23:14:41.568Z","repository":{"id":52443732,"uuid":"520980882","full_name":"kmartins/app_theme_mode","owner":"kmartins","description":"Widgets to control your app theme mode during runtime and save it how you wishing.","archived":false,"fork":false,"pushed_at":"2022-08-04T18:15:46.000Z","size":53,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-23T09:18:29.258Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/kmartins.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":"2022-08-03T17:54:24.000Z","updated_at":"2024-11-21T07:07:12.000Z","dependencies_parsed_at":"2022-09-05T19:42:07.992Z","dependency_job_id":null,"html_url":"https://github.com/kmartins/app_theme_mode","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmartins%2Fapp_theme_mode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmartins%2Fapp_theme_mode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmartins%2Fapp_theme_mode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmartins%2Fapp_theme_mode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kmartins","download_url":"https://codeload.github.com/kmartins/app_theme_mode/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243945611,"owners_count":20372897,"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":"2025-01-23T09:18:31.389Z","updated_at":"2025-03-16T23:14:41.534Z","avatar_url":"https://github.com/kmartins.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# App Theme Mode\n\n[![pub][package_badge]][package_link]\n[![License: MIT][license_badge]][license_link]\n[![codecov][codecov_badge]][codecov_link]\n\nWidgets to control your app **theme mode** during runtime and save it how you wishing.\n\nIt's very similar to [dynamic_theme_mode_package][dynamic_theme_mode_package].\n\n## Why?\n\nThere is no business logic here, only widgets that control the **theme mode**, you choose how you want to save with [SharedPreferences][shared_preferences], [Hive][hive]... any one.\n\n## Usage\n\n```yaml\ndependencies:\n  app_theme_mode:\n```\n\nImport it where you want to use it e.g, in your main file.\n\n```dart\nimport 'package:app_theme_mode/app_theme_mode.dart';\n```\n\nPut the `AppThemeMode` widget, above `MaterialApp/CupertinoApp` or another that had `theme mode`.\n```dart\nAppThemeMode(\n    builder: (context, themeMode) =\u003e MaterialApp(        \n        title: 'Flutter Demo',\n        themeMode: themeMode,\n        darkTheme: ThemeData.dark(),\n        theme: ThemeData.light(),\n        home: const MyHomePage(\n          title: 'Flutter Demo Home Page',\n        ),\n    ),\n);\n```\n\nSet the initial `theme mode`:\n```dart\nAppThemeMode(\n    initialThemeMode: ThemeMode.light // System mode is the default\n    builder: (context, themeMode)...\n);\n```\nGet the `theme mode` saved of your **business logic**.\nThis is set only *_one time_*.\n\nAdd a callback for when a new different `theme mode` is set:\n```dart\nAppThemeMode(\n    onChangeThemeMode: (themeMode) {\n      // call your business logic to save \n      // the current theme mode here.\n    },\n    builder: (context, themeMode)...\n);\n```\n**Here you can call your _logic business_ for the save current `theme mode`.**\n\nYou can access the current `theme mode`:\n```dart\nfinal currentTheme = AppThemeMode.of(context).themeMode;\n```\n**All the time that a new different `theme mode` is set the widget is rebuilt.**\n\nOr set a new `theme mode`:\n```dart\nAppThemeMode.of(context).setThemeMode(ThemeMode.dark);\n// or\nAppThemeMode.of(context).useDarkMode();\n```\n\nThere is a dialog widget called `AppThemeModeDialog` for the user to choose which `theme mode` he wants\n```dart\nIconButton(\n    icon: const Icon(Icons.access_time_sharp),\n    onPressed: () =\u003e showDialog(\n        context: context,\n        builder: (_) =\u003e const AppThemeModeDialog(),\n    ),\n),\n```\n\n## 📝 Maintainers\n\n[Kauê Martins][github_profile]\n\n## 🤝 Support\n\nYou liked this package? Then give it a ⭐️. If you want to help then:\n\n- Fork this repository\n- Send a Pull Request with new features\n- Share this package\n- Create issues if you find a bug or want to suggest a new extension\n\n**Pull Request title follows [Conventional Commits][conventional_commits].\n\n## 📝 License\n\nCopyright © 2022 [Kauê Martins][github_profile].\u003cbr /\u003e\nThis project is [MIT][license_link] licensed.\n\n[package_badge]: https://img.shields.io/pub/v/app_theme_mode.svg\n[package_link]: https://pub.dev/packages/app_theme_mode\n[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg\n[license_link]: https://opensource.org/licenses/MIT\n[codecov_badge]: https://codecov.io/gh/kmartins/app_theme_mode/branch/main/graph/badge.svg\n[codecov_link]: https://codecov.io/gh/kmartins/app_theme_mode\n[shared_preferences]: https://pub.dev/packages/shared_preferences\n[hive]: https://pub.dev/packages/hive\n[conventional_commits]: https://www.conventionalcommits.org/en/v1.0.0/\n[github_profile]: https://github.com/kmartins\n[dynamic_theme_mode_package]: https://pub.dev/packages/dynamic_theme_mode","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkmartins%2Fapp_theme_mode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkmartins%2Fapp_theme_mode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkmartins%2Fapp_theme_mode/lists"}