runWithoutAppOpen<T> method
Convenience: run any async action with app-open ads suppressed. Guaranteed to unblock even if the action throws.
Implementation
Future<T> runWithoutAppOpen<T>(
Future<T> Function() action, {
String reason = 'scoped_action',
Duration timeout = _defaultBlockerTimeout,
/// Small grace period after the action completes — covers the
/// resume animation/lifecycle callback that fires *after* the
/// picker/camera returns.
Duration releaseDelay = const Duration(seconds: 1),
}) async {
blockAppOpen(reason, timeout: timeout);
try {
return await action();
} finally {
Future.delayed(releaseDelay, () => unblockAppOpen(reason));
}
}