showLottieOverlayWhile method
Future<bool>
showLottieOverlayWhile(
- Function callback, {
- Duration? timeout,
- Function? onTimeout,
- String? animationUrl,
- VoidCallback? onHide,
Shortcut to show the animation while a callback
is executed. If provided, after timeout
period, the execution
of callback
will be aborted and (if provided), function onTimeout
will be called.
It returns true if the callback is started; false otherwise (i.e. if the animation is already shown)
Implementation
Future<bool> showLottieOverlayWhile(Function callback,
{Duration? timeout,
Function? onTimeout,
String? animationUrl,
VoidCallback? onHide}) async {
if (_visible) {
return false;
}
_showLottieOverlay(
repetitions: double.maxFinite.toInt(),
animationUrl: animationUrl,
onHide: onHide);
if (timeout == null) {
await callback();
} else {
await callback().timeout(timeout, onTimeout: () async {
if (onTimeout != null) {
onTimeout();
}
});
}
hideLottieOverlay();
return true;
}