我正在尝试将下面的Scaffold呈现到具有StreamBuilder的屏幕上,该屏幕用于从Firestore数据库,带有按钮的底部文本字段中检索文档,但这给了我这个运行时错误。如何解决抖动中的错误?
在performResize()期间引发了以下断言:垂直视口的高度不受限制。
return Scaffold(
appBar: AppBar(title: Text("COMMENTS", textAlign: TextAlign.center,style: TextStyle(color: Colors.white),),centerTitle: true,backgroundColor: Colors.deepOrangeAccent,),
body: Container(
child: Column(
children: <Widget>[
StreamBuilder<QuerySnapshot>(
stream: query.snapshots(),
builder: (context,snapshot){
//String itemTitle = snapshot.data.documents[index]['postContent'];
if (!snapshot.hasData){
return Text("Loading");
}
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index){
String itemTitle = snapshot.data.documents[index]['postContent'];
String postId = snapshot.data.documents[index]["post_id"];
return CardItem(itemTitle:itemTitle, postid: postId,);
});
},
),
Align(
alignment: Alignment.bottomCenter,
child: BottomAppBar(
elevation: 10,
color: Theme.of(context).primaryColor,
child: Container(
constraints: BoxConstraints(
maxHeight: 100,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
IconButton(
icon: Icon(
Icons.add,
color: Theme.of(context).accentColor,
),
onPressed: (){},
),
Flexible(
child: TextField(
style: TextStyle(
fontSize: 15.0,
color: Theme.of(context).textTheme.title.color,
),
decoration: InputDecoration(
contentPadding: EdgeInsets.all(10.0),
border: InputBorder.none,
enabledBorder: InputBorder.none,
hintText: "Write your message...",
hintStyle: TextStyle(
fontSize: 15.0,
color: Theme.of(context).textTheme.title.color,
),
),
maxLines: null,
),
),
IconButton(
icon: Icon(
Icons.mic,
color: Theme.of(context).accentColor,
),
onPressed: (){},
)
],
),
),
),
),
],
),
),
);
在您的情况下,应将streambuilder包装在扩展的小部件中。
这将消除错误。该错误基本上是说,没有固定高度的列表视图占据了无限的高度。