0 purchases
theme genius
ThemeGenius #
A Flutter package that provides a simple way to manage theme modes in your app.
Installation 💻 #
❗ In order to start using ThemeGenius you must have the Flutter SDK installed on your machine.
Install via flutter pub add:
dart pub add theme_genius
copied to clipboard
Or add this to your pubspec.yaml:
dependencies:
theme_genius: ^1.0.1
copied to clipboard
Usage 📖 #
Import the ThemeGeniusWrapper widget, wrap MaterialApp with it:
import 'package:theme_genius/theme_genius.dart';
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return ThemeGeniusWrapper(
builder: (themeMode) {
return MaterialApp(
themeMode: themeMode,
theme: ThemeData.light(),
darkTheme: ThemeData.dark(),
home: const MyHomePage(
title: 'Flutter Demo Home Page',
),
);
},
);
}
}
copied to clipboard
Get the current themeMode with:
final themeMode = await ThemeGenius.getThemeMode(context);
copied to clipboard
Change and save the themeMode with:
final themeMode = ThemeMode.dark;
await ThemeGenius.setThemeMode(context, themeMode: themeMode);
copied to clipboard
Load the saved themeMode with:
final themeMode = await ThemeGenius.loadThemeMode();
copied to clipboard
Check the example folder for a complete example.
Extra 📖 #
Set the defaultThemeMode in ThemeGeniusWrapper with:
@override
Widget build(BuildContext context) {
return ThemeGeniusWrapper(
builder: (themeMode) {
return MaterialApp(...);
},
defaultThemeMode: ThemeMode.dark,
);
}
copied to clipboard
Set a custom placeholder (a widget to display while the theme mode is being loaded) in ThemeGeniusWrapper with:
@override
Widget build(BuildContext context) {
return ThemeGeniusWrapper(
builder: (themeMode) {
return MaterialApp(...);
},
placeholder: const Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
),
);
}
copied to clipboard
Continuous Integration 🤖 #
Theme Genius comes with a built-in GitHub Actions workflow powered by Very Good Workflows but you can also add your preferred CI/CD solution.
Out of the box, on each pull request and push, the CI formats, lints, and tests the code. This ensures the code remains consistent and behaves correctly as you add functionality or make changes. The project uses Very Good Analysis for a strict set of analysis options used by our team. Code coverage is enforced using the Very Good Workflows.
License 📄 #
MIT © 2012-2023 Scott Chacon and others
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.