-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
It would be nice to have an option to "debounce" the Loading Overlay. If I'm not sure whether an asynchronous call will be processed virtually instantaneously or maybe take a bit I will wrap it in the show() and hide calls. However, if the asynchronous call is "too fast", this will result in an annoying "visual pop" where the loader is being shown and then instantly hidden again.
In an extension method I've written to use in future builders I've currently solved this by using a timer:
extension OverlayLoaderExtension on OverlayExtensionHelper {
static Timer? _debounceTimer;
void snapshotLoader(
AsyncSnapshot asyncSnapshot, {
Duration delay = const Duration(milliseconds: 150),
}) {
if (asyncSnapshot.connectionState == ConnectionState.waiting) {
_debounceTimer?.cancel();
_debounceTimer = Timer(delay, () {
show();
});
} else {
_debounceTimer?.cancel();
_debounceTimer = null;
hide();
}
}
}This works very well to prevent the visual "pop" if my data loads quickly.
It would be nice to have a similar option when initialising the overlay to enable a global "debouncing".
Metadata
Metadata
Assignees
Labels
No labels