dynamik_theme 0.0.1 copy "dynamik_theme: ^0.0.1" to clipboard
dynamik_theme: ^0.0.1 copied to clipboard

Easy to use Dynamic Theme for Flutter with automatic persistence support.

Easy to use Dynamic Theme for Flutter with automatic persistence support.

Supported Themes #

  • Light Theme
  • Dark Theme
  • System Mode
  • Dynamic Mode
  • Custom Color

Usage #

void main() {
  /// Set ThemeStorage. If not set InMemoryThemeStorage will be used.
  ThemeConfig.storage = InMemoryThemeStorage();
  runApp(const MyApp());
}
class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return DynamikTheme(
      config: ThemeConfig(
        useMaterial3: true,
        // You can also generate color schemes from:
        // https://m3.material.io/theme-builder#/custom
        lightScheme: ColorScheme.fromSeed(
          seedColor: Colors.red,
        ),
        darkScheme: ColorScheme.fromSeed(
          seedColor: Colors.red,
          brightness: Brightness.dark,
        ),
        defaultThemeState: SimpleThemeType.dynamik.themeData,
        builder: (themeData) {
          // Add more customization on ThemeData.
          return themeData.copyWith(
            appBarTheme: const AppBarTheme(centerTitle: true),
            inputDecorationTheme: const InputDecorationTheme(
              border: OutlineInputBorder(),
            ),
          );
        },
      ),
      builder: (theme, darkTheme, themeMode) {
        return MaterialApp(
          themeMode: themeMode,
          theme: theme,
          darkTheme: darkTheme,
          debugShowCheckedModeBanner: false,
          home: const Home(),
        );
      },
    );
  }
}

Implementing ThemeStorage for persistence. You can use Hive, SharedPreferences or any database of your choice.

class InMemoryThemeStorage implements ThemeStorage {
  ThemeState? _state;

  @override
  Future<void> delete() async {
    _state = null;
  }

  @override
  ThemeState? read() {
    return _state;
  }

  @override
  Future<void> write(ThemeState state) async {
    _state = state;
  }
}

Contributing #

Contributions are welcomed!

Here is a curated list of how you can help:

  • Report bugs and scenarios that are difficult to implement
  • Report parts of the documentation that are unclear
  • Fix typos/grammar mistakes
  • Update the documentation / add examples
  • Implement new features by making a pull-request
9
likes
0
pub points
45%
popularity

Publisher

verified publisherskstha.com.np

Easy to use Dynamic Theme for Flutter with automatic persistence support.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

dynamic_color, flutter

More

Packages that depend on dynamik_theme