waitForFirebaseInit method

Future<void> waitForFirebaseInit()

Implementation

Future<void> waitForFirebaseInit() async {
  int tick = 1;
  bool initialized = false;

  if (!initialized) {
    try {
      FirebaseAuth.instance.app;
      initialized = true;
    } catch (e, es) {
      print(e);
    }
    warn("Waiting for Firebase to Initialize");
    await Future.delayed(Duration(milliseconds: min(1000, 50 * (tick++))));

    if (tick > 60) {
      error("Failed to initialize Firebase");
      throw "Failed to initialize Firebase";
    }
  }
}