我是 Flutter 新手,我正在开发一个简单的应用项目,该项目连接到 Firebase 数据库并获取数据并将其显示在容器中。
问题是当运行代码时我得到“底部被无穷大像素溢出”但在我的数据库中我只有一个记录+并且它没有在脚手架小部件中显示任何数据!!!
数据库包含(问题,答案,正确答案,补偿) 感谢帮助!
我的代码:
class _QuizzScreenState extends State<QuizzScreen> {
// final Future<FirebaseApp> initialization = Firebase.initializeApp();
// FirebaseFirestore firestore = FirebaseFirestore.instance;
// CollectionReference historyQuestion =
// FirebaseFirestore.instance.collection("History");
final String question = '';
final String answerID = '';
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
FutureBuilder(
future: Firebase.initializeApp(),
builder: (context, snapshot) {
if (snapshot.hasError) {
return Scaffold(
body: Center(
child: Text("Error: ${snapshot.error}"),
),
);
}
// Collection Data ready to display
if (snapshot.connectionState == ConnectionState.done) {
// Display the data inside a list view
return snapshot.data.docs.map(
(document) {
return Center(
child: Container(
child: Text(
document.data()['question'],
style: GoogleFonts.elMessiri(
textStyle: TextStyle(
color: Color.fromARGB(255, 56, 241, 193),
letterSpacing: .5,
fontWeight: FontWeight.bold,
fontSize: 17,
),
),
),
),
);
},
);
}
// Loading State
},
),