crazecoder / flutter_bugly

腾讯Bugly flutter应用更新统计及异常上报插件,支持Android、iOS
Other
602 stars 164 forks source link

Zone mismatch. #158

Closed cjltgb520 closed 3 months ago

cjltgb520 commented 1 year ago

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 commented 1 year ago

I have the same problem.

CatEatFishs commented 11 months ago

I have the same problem.

herowws commented 8 months ago

I have the same problem.

crazecoder commented 3 months ago

see https://github.com/crazecoder/flutter_bugly/issues/162