fix: resolve zone mismatch by removing async/unawaited from main
runZonedGuarded's error handler runs in the parent zone, so calling runApp there caused a Flutter zone mismatch with ensureInitialized. Removed the async keyword from main (redundant with runZonedGuarded) and replaced the zone error handler's runApp call with reportError. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
771ac691d9
commit
1aa2926f30
+6
-5
@@ -13,7 +13,7 @@ import 'package:sharedinbox/di.dart';
|
||||
import 'package:sharedinbox/ui/router.dart';
|
||||
import 'package:sharedinbox/ui/screens/crash_screen.dart';
|
||||
|
||||
void main({List<Override> overrides = const []}) async {
|
||||
void main({List<Override> overrides = const []}) {
|
||||
unawaited(
|
||||
runZonedGuarded(
|
||||
() async {
|
||||
@@ -46,10 +46,11 @@ void main({List<Override> overrides = const []}) async {
|
||||
ProviderScope(overrides: overrides, child: const SharedInboxApp()),
|
||||
);
|
||||
},
|
||||
(error, stack) {
|
||||
// Catch unhandled async errors.
|
||||
runApp(CrashScreen(exception: error, stackTrace: stack));
|
||||
},
|
||||
// This handler runs in the parent zone — runApp cannot be called here.
|
||||
// Framework errors are already handled by FlutterError.onError above.
|
||||
(error, stack) => FlutterError.reportError(
|
||||
FlutterErrorDetails(exception: error, stack: stack),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user