registerFutureHandler<T extends Object, R> method

void registerFutureHandler<T extends Object, R>(
  1. Future<R> select(
    1. T
    ),
  2. void handler(
    1. BuildContext context,
    2. AsyncSnapshot<R?> newValue,
    3. void cancel()
    ), {
  3. R? initialValue,
  4. String? instanceName,
})

registers a handler for a Future exactly once on the first build and unregisters is when the widget is destroyed. This handler will only called once when the Future completes. select allows you to register the handler to a member of the of the Object stored in GetIt. If the object itself if the Future pass (x)=>x here If you pass initialValue your passed handler will be executes immediately with that value. All handler get passed in a cancel function that allows to kill the registration from inside the handler. if the Future has completed handler will be called every time until the handler calls cancel or the widget is destroyed

Implementation

void registerFutureHandler<T extends Object, R>(
  Future<R> Function(T) select,
  void Function(BuildContext context, AsyncSnapshot<R?> newValue,
          void Function() cancel)
      handler, {
  R? initialValue,
  String? instanceName,
}) =>
    widget._state.value.registerFutureHandler<T, R?>(select,
        handler: handler,
        initialValueProvider: () => initialValue,
        instanceName: instanceName,
        allowMultipleSubscribers: true);