bugfender / BugfenderSDK-Flutter

Flutter SDK for Bugfender
https://bugfender.com
BSD 3-Clause "New" or "Revised" License
9 stars 13 forks source link

Exception caught by Flutter framework : Zone mismatch #33

Closed joe-mybuzz closed 8 months ago

joe-mybuzz commented 9 months ago

Hello Bugfender team,

I found an error when wrapping the runApp() with the FlutterBugfender.handleUncaughtErrors function:

image

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

Based on this doc, starting with Flutter 3.10, the framework detects mismatches when using Zones and reports them to the console in debug builds. We are currently using Flutter 3.16.5.

Is there a solution for this?

jgimenez commented 9 months ago

Hi @joe-mybuzz , the document you linked states that "calls to WidgetsFlutterBinding.ensureInitialized() should be run in the same zone as calls to runApp()." Have you tried doing that? If that works, may be you can make a PR

joe-mybuzz commented 9 months ago

Hi @jgimenez! Thank you for your reply. I tried it out and what I did was move the WidgetsFlutterBinding.ensureInitialized() and other functions and methods that rely on the WidgetsFlutterBinding.ensureInitialized() to run first into the same closure as runApp().

jgimenez commented 9 months ago

Great, thanks for confirming this works. Then we'll apply the same in the SDK and instructions.