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.dev/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