builder static method
A builder that provides the current dark mode status.
The builder
function is called whenever the theme brightness changes.
Example:
UseDark.builder(
context,
(isDark) => Text(isDark ? 'It is dark' : 'It is light'),
)
Implementation
static Widget builder(
BuildContext ctx, Widget Function(bool isDark) builder) =>
Watch(() {
final dark = UseDark();
dark.mode ??= ref(Theme.of(ctx).brightness == Brightness.dark);
return builder(dark.mode!.value);
});