theme_fusion 1.0.0+2 copy "theme_fusion: ^1.0.0+2" to clipboard
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

[![Pub Version](https://img.shields.io/pub/v/theme_fusion)](https://pub.flutter-io.cn/packages/theme_fusion)
[![GitHub Repo](https://img.shields.io/badge/github-gokul132000/theme__fusion-blue?logo=github)](https://github.com/Gokul132000/theme_fusion)
![License](https://img.shields.io/github/license/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 Switching Demo](assets/theme_fusion_demo.gif)

---

## πŸ–ΌοΈ Theme Preview

### 🌞 Light Mode  
![Light Theme Preview](assets/light_theme.png)

### 🌚 Dark Mode  
![Dark Theme Preview](assets/dark_theme.png)

---

## ✨ 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 const before 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.

11
likes
140
points
0
downloads

Publisher

unverified uploader

Weekly Downloads

A developer-friendly Flutter theme manager that enables easy switching between light and dark mode using identical color property names.

Homepage
Repository (GitHub)
View/report issues

Topics

#flutter #theme #dark-mode #light-theme #dynamic-theme

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on theme_fusion