the app still only shows a blank screen. Here is my main app code:
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
void main() async {
await Firebase.initializeApp();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('Firebase Integration')),
body: Center(child: Text('Hello, Firebase!')),
),
);
}
}
Any help or suggestions would be greatly appreciated!
3
Answers
It looks like you’re missing WidgetsFlutterBinding.ensureInitialized(); before initializing Firebase:
Add WidgetsFlutterBinding.ensureInitialized(); before initializing Firebase. Check the below code for reference.
You should initialize WidgetsFlutterBinding as it is said in other comment, the main in my app with Flutter & Firebase is:
In your case you don’t need to call the
await Environment.initEnvirnoment();
or theProviderScope