theme_fusion 1.0.0+2
theme_fusion: ^1.0.0+2 copied to clipboard
A developer-friendly Flutter theme manager that enables easy switching between light and dark mode using identical color property names.
# ๐ theme_fusion
[](https://pub.dev/packages/theme_fusion)
[](https://github.com/Gokul132000/theme_fusion)

**theme_fusion** is a lightweight and developer-friendly package for real-time dynamic theme switching between **Light** and **Dark** modes โ built with โค๏ธ by [Gokulram M.](https://github.com/Gokul132000)
---
## ๐ฅ Live Demo

---
## ๐ผ๏ธ Theme Preview
### ๐ Light Mode

### ๐ Dark Mode

---
## โจ Features
- ๐ Real-time **light/dark theme switching**
- ๐ก Define your own theme color models
- ๐ง Access and control theme globally
- ๐ง Smooth rebuilds without boilerplate
- ๐ฆ SharedPreferences for persistent themes
- ๐ป Supports Android, iOS, Web, and Desktop
---
## ๐ Installation
Add to your `pubspec.yaml`:
```yaml
dependencies:
theme_fusion: ^1.0.0
Then run:
flutter pub get
๐งช Getting Started #
โ Step 1: Define your custom theme class #
class AppTheme extends BaseThemeColors {
@override
final Color primary;
@override
final Color background;
@override
final Color text;
// Add your own custom color properties here if needed
final Color divider;
final Color button;
const AppTheme({
required this.primary,
required this.background,
required this.text,
required this.divider,
required this.button,
});
}
โ Step 2: Declare light and dark theme values #
const lightTheme = AppTheme(
primary: Color(0xFF1F1F1F),
background: Color(0xFFFFFFFF),
text: Color(0xFF1A1A1A),
divider: Color(0xFF2C2C2C),
button: Color(0xFF1F1F1F),
);
const darkTheme = AppTheme(
primary: Color(0xFF1F1F1F),
background: Color(0xFF121212),
text: Color(0xFFECECEC),
divider: Color(0xFFE0E0E0),
button: Color(0xFFCCCCCC),
);
โ
Step 3: Wrap your app with ThemeFusionApp #
โ ๏ธ Do not use
constbefore the builder to allow dynamic rebuilding.
void main() {
runApp(
ThemeFusionApp<AppTheme>(
light: lightTheme,
dark: darkTheme,
builder: (context) => MyApp(), // don't use const here
),
);
}
โ Step 4: Global theme access #
AppTheme get theme => themeFusionColor<AppTheme>();
bool get isDarkTheme => themeFusion.isDark;
final themeToggle = themeFusion.toggle;
final setLightTheme = themeFusion.setLightMode;
final setDarkTheme = themeFusion.setDarkMode;
Use these anywhere to access the theme or change it on the fly.
โ Step 5: Apply in your UI #
MaterialApp(
theme: ThemeData(
scaffoldBackgroundColor: theme.background,
colorScheme: ColorScheme.fromSeed(
seedColor: theme.primary,
brightness: isDarkTheme ? Brightness.dark : Brightness.light,
),
appBarTheme: AppBarTheme(
backgroundColor: theme.background,
titleTextStyle: TextStyle(
color: theme.text,
fontWeight: FontWeight.w600,
fontSize: 20,
),
),
),
home: Scaffold(
appBar: AppBar(
title: const Text("Theme Fusion"),
actions: [
Switch(
value: isDarkTheme,
onChanged: (_) => themeToggle(),
),
],
),
body: Center(
child: Text(
"Current Mode: ${isDarkTheme ? "Dark" : "Light"}",
style: TextStyle(color: theme.text),
),
),
),
);
๐ Suggested Folder Structure #
lib/
โโโ main.dart
โโโ theme/
โ โโโ app_theme.dart
๐จโ๐ป Created by #
Gokulram M.
GitHub โข Portfolio
๐ License #
MIT License โข See LICENSE file for details.