该应用程序仍然只显示空白屏幕。这是我的主要应用程序代码:
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!')),
),
);
}
}
任何帮助或建议将不胜感激!
看起来您缺少 WidgetsFlutterBinding.ensureInitialized();在初始化 Firebase 之前:
void main() async {
WidgetsFlutterBinding.ensureInitialized(); // Add this line
await Firebase.initializeApp();
runApp(MyApp());
}