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.flutter-io.cn/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.