subscribe static method

StreamSubscription<bool> subscribe({
  1. required void onEnabled()?,
  2. required void onDisabled()?,
})

Returns a StreamSubscription for DemoMode enabled value

Fires onEnabled if the DemoMode is enabled Fires onDisabled if the DemoMode is disabled.

Implementation

static StreamSubscription<bool> subscribe({
  required void Function()? onEnabled,
  required void Function()? onDisabled,
}) {
  final notify = (isEnabled) {
    if (isEnabled) {
      onEnabled?.call();
    }

    if (!isEnabled) {
      onDisabled?.call();
    }
  };

  notify(isEnabled);

  return _onDemoModeChanged.stream.listen(notify);
}