reactive_theme 2.0.0 copy "reactive_theme: ^2.0.0" to clipboard
reactive_theme: ^2.0.0 copied to clipboard

A simple pkg that toggles between light , dark mode and persists it.

example/lib/main.dart

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

void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    //Wrap with [Reactive Themer] Widget
    return ReactiveThemer(
      builder: (reactiveMode) => MaterialApp(
        debugShowCheckedModeBanner: false,
        themeMode: reactiveMode,
        title: 'Reactive Theme Demo',
        theme: ThemeData(
          colorScheme: ColorScheme.fromSeed(
              brightness: Brightness.light, seedColor: Colors.deepPurple),
          useMaterial3: true,
        ),
        darkTheme: ThemeData(
          colorScheme: ColorScheme.fromSeed(
              brightness: Brightness.dark, seedColor: Colors.deepPurple),
          useMaterial3: true,
        ),
        home: const HomePage(),
      ),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          //Change Theme Using these [ReactiveSwitch]
          const Center(child: ReactiveSwitch()),
          const SizedBox(height: 20),
          //Change Theme Using these [ReactiveThemeBtn]
          const Center(child: ReactiveThemeBtn()),
          const SizedBox(height: 20),
          //Accessible Bool for checking isDarkmode and !isDarkmode
          ReactiveMode.isDarkMode(context)
              ? const Text('is darkmode')
              : const Text('is not darkmode changed'),
        ],
      ),
    );
  }
}
7
likes
150
points
436
downloads

Publisher

unverified uploader

Weekly Downloads

A simple pkg that toggles between light , dark mode and persists it.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, shared_preferences

More

Packages that depend on reactive_theme