postFrameDebounced<T> method
PostFrameTask<T>
postFrameDebounced<T>(
- FutureOr<
T> action(), { - Object? debounceKey,
- List<
ScrollController> scrollControllers = const [], - int maxWaitFrames = 5,
- bool waitForEndOfFrame = true,
- int endOfFramePasses = 2,
- Duration? timeout,
- PostFramePredicate? predicate,
- void onError(
- Object error,
- StackTrace stackTrace
Debounced post-frame run with context-aware mounted check.
Similar to postFrameRun but with debouncing capability.
Implementation
PostFrameTask<T> postFrameDebounced<T>(
FutureOr<T> Function() action, {
Object? debounceKey,
List<ScrollController> scrollControllers = const [],
int maxWaitFrames = 5,
bool waitForEndOfFrame = true,
int endOfFramePasses = 2,
Duration? timeout,
PostFramePredicate? predicate,
void Function(Object error, StackTrace stackTrace)? onError,
}) {
// Capture the element for mounted check.
final element = this as Element;
return PostFrame.debounced<T>(
action,
debounceKey: debounceKey,
scrollControllers: scrollControllers,
maxWaitFrames: maxWaitFrames,
waitForEndOfFrame: waitForEndOfFrame,
endOfFramePasses: endOfFramePasses,
timeout: timeout,
predicate: () {
// Check if widget is still mounted.
if (!element.mounted) return false;
// Apply additional predicate if provided.
return predicate?.call() ?? true;
},
onError: onError,
);
}