Published 2025-09-04
Widgets and models to toggle between light and dark mode.

Wrap a provider for the HHDarkModeModel, and a consumer, in your application widget:
class YourApp extends StatelessWidget {
const YourApp({final Key? key}) : super(key: key);
@override
Widget build(final BuildContext context) =>
HHProvider<HHDarkModeModel>(
create: (final _) => HHDarkModeModel(),
child: HHConsumer<HHDarkModeModel>(
builder: (final context, final darkModeModel, final child) => MaterialApp(
title: kApplicationTitle,
theme: ThemeData.light(),
darkTheme: ThemeData.dark(),
themeMode: darkModeModel.mode,
debugShowCheckedModeBanner: false,
home: ... your home page ...,
),
),
);
}
Use the HHDarkModeToggleButton somewhere to toggle between light/dark mode.
@override
Widget build(final BuildContext context) =>
Scaffold(
appBar: AppBar(
title: Text(widget.title),
actions: [
const HHDarkModeToggleButton(),
],
),
body: ... your home page body ...
HHDarkModeModel.isSystemDarkmode to test if the operating system is in dark mode.HHDarkModeToggleButton.color.inAppBar flag on HHDarkModeToggleButton.DarkModeToggleButton to HHDarkModeToggleButton.ThemeModel to HHDarkModeModel.StorageManager class and replaced with HHPreferences from pkg_core.await unawaited futures.unawaited.provider dependency.CHANGELOG.md.print statements for logging.