SubValueListener<T> constructor

SubValueListener<T>({
  1. required ValueListenable<T> listenable,
  2. required SubValueBuild<T> builder,
  3. ValueChanged<T>? listener,
  4. bool initialize = false,
})

Subscribes to a ValueListenable and returns its value.

  • 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

SubValueListener({
  required ValueListenable<T> listenable,
  required SubValueBuild<T> builder,
  ValueChanged<T>? listener,
  super.initialize,
}) : super(
        listenable: listenable,
        listener: listener != null ? () => listener(listenable.value) : null,
        builder: (context) => ValueListenableBuilder<T>(
          valueListenable: listenable,
          builder: (context, value, child) => builder(context, value),
        ),
      );