DeferInit<T extends Widget?> constructor
const
DeferInit<T extends Widget?> ({
- Key? key,
- required OnDeferInit<
T> onDefer, - Widget loadingWidget = const SizedBox.shrink(),
- Widget emptyWidget = const SizedBox.shrink(),
Prevents the initialization of UI until the provided asynchronous task is completed.
This is done by using the deferFirstFrame()
and allowFirstFrame()
functions from Flutter's RendererBinding mixin.
Use in a StatefulWidget when async initialization of a service
class is required before initState
starts to build UI.
This widget was created by Simon Lightfoot and modified slightly by GroovinChip. Please view the original source here
Implementation
const DeferInit({
super.key,
required this.onDefer,
this.loadingWidget = const SizedBox.shrink(),
this.emptyWidget = const SizedBox.shrink(),
});