builder static method

Widget builder(
  1. BuildContext ctx,
  2. Widget builder(
    1. bool isDark
    )
)

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);
    });