我正在尝试为我的Flutter应用程序构建一个简单的登录页面.我已经成功构建了TextFields和Login/Signin按钮.我想添加一个水平ListView.当我运行代码时,我的元素消失,如果我没有ListView,它再次没问题.我该怎么做才能正确?
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: new Text("Login / Signup"),
),
body: new Container(
child: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new TextField(
decoration: new InputDecoration(
hintText: "E M A I L A D D R E S S"
),
),
new Padding(padding: new EdgeInsets.all(15.00)),
new TextField(obscureText: true,
decoration: new InputDecoration(
hintText: "P A S S W O R D"
),
),
new Padding(padding: new EdgeInsets.all(15.00)),
new TextField(decoration: new InputDecoration(
hintText: "U …Run Code Online (Sandbox Code Playgroud) 在尝试实现flutter-firebase 时,ListView.builder未能显示!
请注意,当我尝试在没有ListView.builder它的情况下显示第一个元素时,它工作正常,即错误仅与此代码块相关:
return ListView.builder(
itemCount: snapshot.data.documents.length,
padding: const EdgeInsets.only(top: 10.0),
itemExtent: 25.0,
itemBuilder: (context, index) {
DocumentSnapshot ds = snapshot.data.documents[index];
return Text(" ${ds['name']} ${ds['vote']}");
});
Run Code Online (Sandbox Code Playgroud)
我的完整代码是:
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
void main() => runApp(MyApp(
textInput: Text("Text Widget"),
));
class MyApp extends StatefulWidget {
final Widget textInput;
MyApp({this.textInput});
@override
State<StatefulWidget> createState() => MyAppState();
}
class MyAppState extends State<MyApp> {
bool checkBoxValue = false;
@override
Widget build(BuildContext ctxt) {
return new MaterialApp(
home: SafeArea(
child: …Run Code Online (Sandbox Code Playgroud)