useAllReady function
bool
useAllReady({
- void onReady(
- BuildContext context
- void onError(
- BuildContext context,
- Object error
- Duration? timeout,
Implementation
bool useAllReady(
{void Function(BuildContext context)? onReady,
void Function(BuildContext context, Object error)? onError,
Duration? timeout}) {
return use(_WatchFutureHook<Object, bool>(
instanceName: null,
select: null,
preserveState: true,
handler: (context, x, dispose) {
if (x.hasError) {
onError?.call(context, x.error!);
} else {
onReady?.call(context);
(context as Element).markNeedsBuild();
}
dispose();
},
initialValueProvider: () => GetIt.I.allReadySync(),
/// as `GetIt.allReady` returns a Future<void> we convert it
/// to a bool because if this Future completes the meaning is true.
futureProvider: () => GetIt.I.allReady(timeout: timeout).then((_) => true),
)).data!;
}