theme_setting 0.0.5 copy "theme_setting: ^0.0.5" to clipboard
theme_setting: ^0.0.5 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, and JSON color utilities.


✨ 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

πŸš€ Getting Started #

Installation #

Add this to your pubspec.yaml:

dependencies:
  theme_setting: ^0.0.5

πŸ”§ 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 #

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

🌈 Supported Themes #

enum SupportedThemeName {
  primary,
  green,
  brown,
  pink,
  orange,
}

You can expand on this enum to support custom themes in your app.


πŸ”„ 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';

πŸ“’ 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
0
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

License

unknown (license)

Dependencies

flutter, flutter_bloc, get_it_di_global_variable, hydrated_bloc

More

Packages that depend on theme_setting