registerFutureHandler<T extends Object, R> method
void
registerFutureHandler<T extends Object, R>(
- Future<
R> select(- T
- void handler(
- BuildContext context,
- AsyncSnapshot<
R?> newValue, - void cancel()
- R? initialValue,
- 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,
}) {
_state.value.registerFutureHandler<T, R?>(select,
handler: handler,
initialValueProvider: () => initialValue,
instanceName: instanceName,
allowMultipleSubscribers: true);
}