stacked_themes
0.3.16, released 8 weeks ago by filledstacks.com
Manage multiple themes, dark mode, and theme persistence in Flutter applications.
What it does
It provides a ThemeManager, ThemeBuilder widget, and ThemeService to easily swap between multiple ThemeData configurations or toggle light and dark modes. It handles theme persistence using shared_preferences and includes status bar color updates.
AI-written summary of version 0.3.16, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to manage more than just a simple light and dark theme (multiple themes)
- You want automatic persistence of the user's selected theme across app restarts
- You are using the Stacked architecture and want a ThemeService for your view models
Skip it when
- you prefer using Riverpod or Bloc for all state management including themes
- You only need standard Flutter ThemeMode toggling without extra utilities
Strengths
- Supports multiple themes beyond just light and dark
- Built-in theme persistence via shared_preferences
- Includes business logic access via ThemeService for ViewModels
Weaknesses
- Tied to the Stacked ecosystem conventions
- Adds several third-party dependencies for what can be done natively
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 7
Awaiting ThemeManager.initialise() in main function before running the app.
Future main() async {
await ThemeManager.initialise();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ThemeBuilder(
builder: (context, regularTheme, darkTheme, themeMode) => MaterialApp(
title: 'Flutter Demo',
theme: regularTheme,
darkTheme: darkTheme,
themeMode: themeMode,
),
);
}
}Alternatives
Packages that do the same job and could replace stacked_themes.
- theme_extensions_builder
Code generator for Flutter ThemeExtension classes to minimize boilerplate code.
77Compare - theme_tailor
Generates boilerplate for Flutter ThemeExtension classes using annotations.
89Compare - xdg_icons
XDG theme icons for Flutter.
62Compare - random_color_scheme
Generates random light and dark Material Design color schemes respecting WCAG guidelines.
57Compare
Works with
Packages commonly used together with stacked_themes: ones it builds on, ones built on it, and its own family.
- shared_preferencesstacked_themes depends on itFlutter plugin for reading and writing simple key-value pairs. Wraps NSUserDefaults on iOS and SharedPreferences on Android.
- rxdartstacked_themes depends on itImplementation of the ReactiveX API for asynchronous programming leveraging native Dart Streams.
- universal_iostacked_themes depends on itCross-platform dart:io implementation with browser support for HttpClient and other APIs
- get_itstacked_themes depends on itA fast, type-safe service locator for Dart and Flutter without BuildContext or code generation.
- providerstacked_themes depends on itA lightweight wrapper around InheritedWidget for state management
- stacked_sharedstacked_themes depends on itShared code between the stacked packages.
- flutter_statusbarcolor_nsstacked_themes depends on itProgrammatically change status bar and navigation bar colors in Flutter apps.
- stackedSame familyA complete frontend architecture framework for building Flutter applications.