Starting from Flutter 3.10.0, there is a check for a "Zone Mismatch". Considering that bugsnag.start() creates a new zone, in cases where user wants to run WidgetsFlutterBinding.ensureInitialized(); there is a need to access the same zone. Otherwise, there will be zone mismatch error thrown.
Steps to reproduce
Create a new Flutter application using version ^3.10.0.
In the main method, add:
dart```
WidgetsFlutterBinding.ensureInitialized();
bugsnag.start(...);
Run the app and observe the framework error.
Environment
Bugsnag version: "2.4.0"
Flutter version: "3.10.5"
Flutter-first app or native app with Flutter component(s): Flutter-first
iOS/Android version: iOS 14
Simulator/emulator or physical device: Simulator
Error messages:
```
════════ 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
#0 BindingBase.debugCheckZone.
binding.dart:497åc
#1 BindingBase.debugCheckZone
binding.dart:502
#2 runApp
binding.dart:1080
#3 main.
main.dart:120
#4 Bugsnag.attach.
client.dart:631
#5 Bugsnag._runWithErrorDetection.
client.dart:764
#10 Bugsnag._runWithErrorDetection
client.dart:763
#11 Bugsnag.attach
client.dart:629
(elided 4 frames from dart:async)
════════════════════════════════════════════════════════════════════════════════
```
Starting from Flutter 3.10.0, there is a check for a "Zone Mismatch". Considering that
bugsnag.start()
creates a new zone, in cases where user wants to runWidgetsFlutterBinding.ensureInitialized();
there is a need to access the same zone. Otherwise, there will be zone mismatch error thrown.Steps to reproduce
^3.10.0
.Environment
Error messages:
``` ════════ 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 #0 BindingBase.debugCheckZone.