Observer<T> constructor

Observer<T>({
  1. required Of<T> of,
  2. @Deprecated("Replaced by 'builder'") _OfBuilder<T>? child,
  3. _OfBuilder<T>? builder,
  4. List<Of> slaves = const [],
})

Definition

Observer: To watch changes of a specific object, send this one(the object) as value of the property of,

and provide a widget builder that will be used when your watched object changes.

Parameters

of: Master observable to bind with this observer.

child: Widget builder of this observer.

slaves: Additional observables that should be bound to this observer. This parameter is optional.

Usage

To use this, you should first setup the provider for this type. Meaning you should

send the general instance of this type in KareeMaterialApp to watch it in all your application.

  final counter = Of(0);
  Observer.on<int>(
    of: counter,
    child: (ctx) {
    return Text('Counter value ${counter.value}');
  }),

See Observer.withProviders

See also Observer.on

Implementation

Observer(
    {required Of<T> of,
    @Deprecated("Replaced by 'builder'") _OfBuilder<T>? child,
    _OfBuilder<T>? builder,
    List<Of> slaves = const []})
    : assert(builder != null || child != null),
      super(of, (builder ?? child)!, slaves);