Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions lib/core/catcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Catcher with ReportModeAction {
final Widget? rootWidget;

///Run app function which will be ran
final void Function()? runAppFunction;
final FutureOr<void> Function()? runAppFunction;

/// Instance of catcher config used in release mode
CatcherOptions? releaseConfig;
Expand Down Expand Up @@ -206,20 +206,18 @@ class Catcher with ReportModeAction {
runApp(rootWidget!);
});
} else if (runAppFunction != null) {
_runZonedGuarded(() {
runAppFunction!();
});
_runZonedGuarded(runAppFunction!);
} else {
throw ArgumentError("Provide rootWidget or runAppFunction to Catcher.");
}
}

void _runZonedGuarded(void Function() callback) {
void _runZonedGuarded(FutureOr<void> Function() callback) {
runZonedGuarded<Future<void>>(() async {
if (ensureInitialized) {
WidgetsFlutterBinding.ensureInitialized();
}
callback();
await callback();
}, (dynamic error, StackTrace stackTrace) {
_reportError(error, stackTrace);
});
Expand Down