【发布时间】:2022-10-06 20:15:25
【问题描述】:
我刚刚创建了一个新的颤振应用程序并尝试连接一个新制作的 Firebase Firestore。添加了 Cli 并运行了 flutterfire 配置。
import \'package:flutter/material.dart\';
import \'package:firebase_core/firebase_core.dart\';
import \'firebase_options.dart\';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform
);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
home: FutureBuilder(builder: ((context, snapshot) {
if(snapshot.hasError){
print(\'Error\');
}
if(snapshot.connectionState == ConnectionState.done){
return const MyHomePage(title: \'WOWZA\',);
}
return CircularProgressIndicator();
}
)
)
);
}
}
在 if(snapshot.connectionState == ConnectionState.done) 中断时说 connectionState 是 .none 并且不确定原因。
任何人都可以帮忙吗?
-
我认为你需要为你的 FutureBuilder 添加一个未来
标签: flutter firebase google-cloud-firestore flutter-web