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!
>Solution :
It looks like you’re missing WidgetsFlutterBinding.ensureInitialized(); before initializing Firebase:
void main() async {
WidgetsFlutterBinding.ensureInitialized(); // Add this line
await Firebase.initializeApp();
runApp(MyApp());
}