Reputation: 77
i am facing this error for 3 days, i have just used firebase db for authentication, and i don't know how to solve it
Upvotes: 5
Views: 6556
Reputation: 41
You need to initialize the widget rendering or binding process before the asynchronous call
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(const App());
}
Upvotes: 2
Reputation: 2425
As per their error, answer is contained inside:
Add this WidgetsFlutterBinding.ensureInitialized();
before runApp(const MyApp());
inside main()
Upvotes: 14
Reputation: 81
Try this...
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(const MyApp());
}
Upvotes: 7