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解决方法 #162

Open
crazecoder opened this issue Aug 29, 2024 · 0 comments
Open

关于Zone mismatch解决方法 #162

crazecoder opened this issue Aug 29, 2024 · 0 comments

Comments

@crazecoder
Copy link
Owner

crazecoder commented Aug 29, 2024

出现如下报错时

════════ 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() { }`).
[...]
═══════════════════════════════════════════════════════════════════════════════════

使用下面方法解决

void main(){
    runZonedGuarded(() {
      WidgetsFlutterBinding.ensureInitialized();
      runApp(MyApp());
    }, (exception, stackTrace) {
      FlutterBugly.uploadException(message: exception.toString(),detail: stackTrace.toString());
    });
}
@crazecoder crazecoder pinned this issue Aug 29, 2024
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

1 participant