flutter_easy_theme 1.0.0 copy "flutter_easy_theme: ^1.0.0" to clipboard
flutter_easy_theme: ^1.0.0 copied to clipboard

A lightweight Flutter package for theme management with persistent theme mode support.

example/lib/main.dart

import 'package:flutter_easy_theme/flutter_easy_theme.dart';
import 'package:flutter/material.dart';

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

  runApp(
    EasyTheme(
      lightTheme: ThemeData.light(),
      darkTheme: ThemeData.dark(),
      child: const MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: context.lightTheme,
      darkTheme: context.darkTheme,
      themeMode: context.themeMode,
      home: const HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Easy Theme')),
      body: Center(
        child: Column(
          mainAxisAlignment: .center,
          spacing: 10,
          children: [
            ElevatedButton(
              onPressed: () {
                context.toggleTheme();
              },
              child: const Text('Toggle Theme'),
            ),
            ElevatedButton(
              onPressed: () {
                context.setThemeModeToLight();
              },
              child: const Text('Set to light'),
            ),
            ElevatedButton(
              onPressed: () {
                context.setThemeModeToDark();
              },
              child: const Text('Set to dark'),
            ),
            ElevatedButton(
              onPressed: () {
                context.setThemeModeToSystem();
              },
              child: const Text('Set to system'),
            ),
          ],
        ),
      ),
    );
  }
}
1
likes
160
points
37
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A lightweight Flutter package for theme management with persistent theme mode support.

Repository (GitHub)
View/report issues

Topics

#theme #dark-theme #light-theme #flutter

License

MIT (license)

Dependencies

flutter, shared_preferences

More

Packages that depend on flutter_easy_theme