easy_dynamic_theme 0.0.2 copy "easy_dynamic_theme: ^0.0.2" to clipboard
easy_dynamic_theme: ^0.0.2 copied to clipboard

outdated

Automatically get your OS defined Theme (Dynamic), force your prefered one (Light / Dark) and of course, persist this choice in your device.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:easy_dynamic_theme/easy_dynamic_theme.dart';
import 'theme.dart';
import 'home.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  SharedPreferences sp = await SharedPreferences.getInstance();
  bool isDark = sp.getBool('is_dark');

  ThemeMode initialThemeMode;
  if (isDark != null) {
    initialThemeMode = isDark ? ThemeMode.dark : ThemeMode.light;
  }

  runApp(
    EasyDynamicThemeWidget(
      initialThemeMode: initialThemeMode,
      child: MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  final String title = 'Dynamic Theme';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: title,
        theme: lightThemeData,
        darkTheme: darkThemeData,
        themeMode: EasyDynamicTheme.of(context).themeMode,
        home: new MyHomePage(
          title: title,
        ));
  }
}
119
likes
0
pub points
92%
popularity

Publisher

verified publisherrlazom.dev

Automatically get your OS defined Theme (Dynamic), force your prefered one (Light / Dark) and of course, persist this choice in your device.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, flutter_web_plugins, shared_preferences

More

Packages that depend on easy_dynamic_theme