reactive_theme 1.0.0
reactive_theme: ^1.0.0 copied to clipboard
A simple pkg that changes thememode and persists it.
reactive_theme #
This package allows you to change theme of the app to light and dark mode and vice versa
with the help of ReactiveThemer
and ReactiveThemeBtn
widgets.
Supports Android, iOS, Web, Mac, Linux and Windows.
What it can do #
You can easily toogle between light mode and dark mode using the ReactiveThemeBtn
provided by
this package.
![](https://github.com/dev-o-los/reactive_theme/blob/main/gifs/reactive_theme_example.gif)
You need not to worry about preserving the theme using shared_preferences as it already preserves the theme state of the app automatically using shared_preferences
package.😎
Install it #
You can install simple_sizer using the below command:
$ flutter pub add reactive_theme
Import it #
Now in your dart
file you can use:
import 'package:reactive_theme/reactive_theme.dart';
Usage #
Wrap the MaterialApp
widget with ReactiveThemer
and nothing else.
⚠️ [Important]
ReactiveThemer
must be the topmost widget in the widget tree
ReactiveThemer(
child: MaterialApp(
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(),
),
);
Now you change toggle between dark and light mode easily from anywhere by using
ReactiveThemeBtn
Widget
ReactiveThemeBtn()
reactive_theme
has two more named constructors you can use if you don't like the default
ReactiveThemeBtn
, they are --
//Helps you modify the original button
ReactiveThemeBtn.editable()
and
//Create your own button
//It takes widget as a parameter
//So , you can make anything you want to
//like a switcher , floating action button etc...
ReactiveThemeBtn.fromScratch()