registerHandler<T extends Object, R> method

void registerHandler<T extends Object, R>(
  1. ValueListenable<R> select(
    1. T
    ),
  2. void handler(
    1. BuildContext context,
    2. R newValue,
    3. void cancel()
    ), {
  3. bool executeImmediately = false,
  4. String? instanceName,
})

registers a handler for a ValueListenable exactly once on the first build and unregisters is when the widget is destroyed. select allows you to register the handler to a member of the of the Object stored in GetIt. If the object itself if the ValueListenable pass (x)=>x here If you set executeImmediately to true the handler will be called immediately with the current value of the ValueListenable. All handler get passed in a cancel function that allows to kill the registration from inside the handler.

Implementation

void registerHandler<T extends Object, R>(
  ValueListenable<R> Function(T) select,
  void Function(BuildContext context, R newValue, void Function() cancel)
      handler, {
  bool executeImmediately = false,
  String? instanceName,
}) =>
    widget._state.value.registerHandler<T, R>(select, handler,
        instanceName: instanceName, executeImmediately: executeImmediately);