filiph / tictactoe

BSD 3-Clause "New" or "Revised" License
429 stars 145 forks source link

Zone mismatch error #17

Open champ96k opened 11 months ago

champ96k commented 11 months ago

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 commented 5 months ago

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