Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Zone mismatch error #17

Open
champ96k opened this issue Nov 29, 2023 · 1 comment
Open

Zone mismatch error #17

champ96k opened this issue Nov 29, 2023 · 1 comment

Comments

@champ96k
Copy link

champ96k commented Nov 29, 2023

Error log

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

Yes i already this Zone mismatch Migration guide but it don't work

Future<void> main() async {
  FirebaseCrashlytics? crashlytics;

  if (!kIsWeb && (Platform.isIOS || Platform.isAndroid)) {
    try {
      WidgetsFlutterBinding.ensureInitialized();
      await Firebase.initializeApp(
        options: DefaultFirebaseOptions.currentPlatform,
      );
      crashlytics = FirebaseCrashlytics.instance;
    } catch (e) {
      debugPrint("Firebase couldn't be initialized: $e");
    }
  }

  await guardWithCrashlytics(
    guardedMain,
    crashlytics: crashlytics,
  );
}
void guardedMain() async {
   /// other code
    runApp();
}

@filiph Do you have any thoughts about it?

@ayushhthakurr
Copy link

ayushhthakurr commented May 14, 2024

Hi @filiph ,
I came across an issue in our Tic Tac Toe app regarding a "Zone mismatch" error, and I believe I have a solution to resolve it.The error arises from inconsistencies in how the Flutter bindings are initialized and when runApp is called. By ensuring that the Flutter bindings are initialized in the same zone as when runApp is invoked, we can mitigate this issue.

I'm eager to contribute to resolving this issue and improving the stability of our app. Could you please assign me this task?

Best regards,
Ayush

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants