theme_setting 0.1.1 copy "theme_setting: ^0.1.1" to clipboard
theme_setting: ^0.1.1 copied to clipboard

A lightweight Flutter package for managing app themes and persistent dark mode using hydrated_bloc. Includes theme switching widget, JSON color utilities, and get_it integration.

theme_setting #

A lightweight and customizable Flutter package for managing app themes and dark mode, featuring persistent state management using hydrated_bloc. It provides a dark mode toggle widget, theme enum support, JSON color utilities, and a builder widget for applying theme-aware UI.


✨ Features #

  • Toggle dark mode with state persistence
  • Hydrated BLoC integration
  • Singleton-based color conversion utility
  • get_it integration for dependency injection
  • Easy-to-use widget for theme switching
  • Builder widget (AppThemeBuilder) to apply theme-aware UI

πŸš€ Getting Started #

Installation #

Add this to your pubspec.yaml:

dependencies:
  theme_setting: <latest_version>

πŸ”§ Usage #

1. Register the Theme Cubit #

import 'package:global/get_it_di.dart';
import 'package:theme_setting/theme_setting.dart';

void themeSettingGetItRegister() {
  sl.registerLazySingleton(() => DarkModeHydratedCubit());
}

2. Use the Theme Switch Widget #

import 'package:theme_setting/theme_setting.dart';

class SettingsPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ThemeSwitchDarkModeHydratedCubitImpl(),
    );
  }
}

3. Apply Theme Based on Cubit State (Manual Integration) #

BlocBuilder<DarkModeHydratedCubit, bool>(
  builder: (context, isDark) {
    return MaterialApp(
      theme: isDark ? ThemeData.dark() : ThemeData.light(),
      home: MyHomePage(),
    );
  },
);

4. Use AppThemeBuilder for Theme-Aware Widgets #

import 'package:theme_setting/theme_setting.dart';

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return AppThemeBuilder(
      child: MaterialApp(
        home: MyHomePage(),
      ),
    );
  }
}

AppThemeBuilder listens to DarkModeHydratedCubit and rebuilds the widget tree when dark mode changes.


πŸ”„ Color JSON Utility #

final colorJson = JsonColorUtil.convertColorToJson(Colors.blue);
final color = JsonColorUtil.convertJsonToColor(colorJson);

πŸ“¦ Exports #

export 'theme_bloc.dart';
export 'theme_event.dart';
export 'theme_state.dart';
export 'package:theme_setting/view_models/dark_mode_hydrated_cubit/dark_mode_hydrated_cubit.dart';
export 'package:theme_setting/widgets/theme_switch_dark_mode_hydrated_cubit_impl.dart';
export 'package:theme_setting/widgets/app_theme_builder.dart';

πŸ“’ Contributions #

Contributions and issues are welcome! Feel free to fork the repository and make pull requests.


πŸ“š License #

MIT License. See LICENSE for details.

1
likes
150
points
14
downloads

Publisher

unverified uploader

Weekly Downloads

A lightweight Flutter package for managing app themes and persistent dark mode using hydrated_bloc. Includes theme switching widget, JSON color utilities, and get_it integration.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_bloc, get_it_di_global_variable, hydrated_bloc, provider

More

Packages that depend on theme_setting