Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zone mismatch. #158

Closed
cjltgb520 opened this issue Oct 27, 2023 · 4 comments
Closed

Zone mismatch. #158

cjltgb520 opened this issue Oct 27, 2023 · 4 comments

Comments

@cjltgb520
Copy link

cjltgb520 commented Oct 27, 2023

runapp 前面加上 WidgetsFlutterBinding.ensureInitialized(); 在flutter 3.10 及更高版本会报出异常

void main() {
WidgetsFlutterBinding.ensureInitialized();
FlutterBugly.postCatchedException(() => runApp(MyApp()));
}

======== Exception caught by Flutter framework =====================================================
The following assertion was thrown during runApp:
Zone mismatch.

The Flutter bindings were initialized in a different zone than is now being used. This will likely cause confusion and bugs as any zone-specific configuration will inconsistently use the configuration of the original binding initialization zone or this zone based on hard-to-predict factors such as which zone was active when a particular callback was set.
It is important to use the same zone when calling ensureInitialized on the binding as when calling runApp later.
To make this warning fatal, set BindingBase.debugZoneErrorsAreFatal to true before the bindings are initialized (i.e. as the first statement in void main() { }).
When the exception was thrown, this was the stack:
BindingBase.debugCheckZone. (package:flutter/src/foundation/binding.dart:503:29)
BindingBase.debugCheckZone (package:flutter/src/foundation/binding.dart:508:6)
runApp (package:flutter/src/widgets/binding.dart:1093:18)
main. (package:flutter_bugly_example/main.dart:7:43)
FlutterBugly.postCatchedException. (package:flutter_bugly/src/flutter_bugly.dart:101:15)
FlutterBugly.postCatchedException (package:flutter_bugly/src/flutter_bugly.dart:100:5)
main (package:flutter_bugly_example/main.dart:7:16)
_runMain. (dart:ui/hooks.dart:159:23)
_delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:296:19)
_RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)
(elided 4 frames from dart:async)

@Howard2595
Copy link

I have the same problem.

2 similar comments
@CatEatFishs
Copy link

I have the same problem.

@herowws
Copy link

herowws commented Mar 4, 2024

I have the same problem.

@crazecoder
Copy link
Owner

see #162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants