SubValueNotifier<T> constructor

SubValueNotifier<T>({
  1. required T initialData,
  2. required SubValueBuild<ValueNotifier<T>> builder,
  3. ValueChanged<T>? listener,
  4. bool initialize = false,
  5. SubValueKeys? keys,
})

Creates and subscribes to a ValueNotifier, then exposes its current state. The notifier is automatically disposed.

  • The optional listener is called when the listenable notifies.
  • If initialize is true, then listener is also called once this Widget is built for the first time.

Implementation

SubValueNotifier({
  required T initialData,
  required SubValueBuild<ValueNotifier<T>> builder,
  ValueChanged<T>? listener,
  bool initialize = false,
  super.keys,
}) : super(
        create: () => ValueNotifier<T>(initialData),
        builder: (context, notifier) => SubValueListener<T>(
          listenable: notifier,
          listener: listener,
          initialize: initialize,
          builder: (context, value) => builder(context, notifier),
        ),
      );