Skip to content

guardWithCrashlytics in game_template is causing issues after upgrading to 3.10 #1818

Closed
@githubmonkey

Description

@githubmonkey

Flutter 3.10 includes a breaking change related to zone initialization.
flutter/flutter#122836

The game_template sample is using guardWithCrashlytics() to run call runApp() inside a new zone. When calling guardWithCrashlytics in main.dart, a previously instantiated crashlytics object is passed in. To obtain that object, WidgetsFlutterBinding.ensureInitialized(); is called in a different zone . This is no longer allowed.

Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: 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() { }`).. Error thrown during runApp.
       at BindingBase.debugCheckZone.<fn>(binding.dart:497)
       at BindingBase.debugCheckZone(binding.dart:502)
       at .runApp(binding.dart:1080)
       at .guardedMain(main.dart:76)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions