import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_firebase_test/firebase_options.dart';
void main() async {
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,);
runApp(const MyApp());
}
when i remove two line of code it work fine.
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,);
Ui should be loaded as it is before.
2
Answers
you need to add
WidgetsFlutterBinding.ensureInitialized();
.When you write the main method as asynchronous, and you run a Flutter app, the asynchronous method waits for the Firebase connection. As a result, your UI will be paused. To avoid this problem, you can write it like this:
So try to avoid main method as as async and also not write await method in main method