我需要基于日期选择构建一个动态列表视图,然后我将调用一个api获取数据并相应地填充列表。然后在列表视图本身的尽头,我有一个向下按钮,按下该按钮应该打开一个扩展面板。要做一个列表,我调用一个函数Widget buildDynamicList(BuildContext context)以根据新数据动态填充新列表。我收到此错误。
I/flutter ( 3438): The following assertion was thrown during performResize():
I/flutter ( 3438): Vertical viewport was given unbounded height.
I/flutter ( 3438): Viewports expand in the scrolling direction to fill their container.In this case, a vertical
I/flutter ( 3438): viewport was given an unlimited amount of vertical space in which to expand. This situation
I/flutter ( 3438): typically happens when a scrollable widget is nested inside another scrollable widget.
在下面的第一列中,我画一张卡片,在其中选择日期,在下面的下一列中,我将此函数称为buildDynamicList(context)
new Column(
children: <Widget>[
Container(
margin: new EdgeInsets.fromLTRB(20, 10, 0, 0),
decoration: new BoxDecoration(
color:Color.fromRGBO(36, 46, 66, 1),
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(35),
bottomLeft: const Radius.circular(35)
),
),
width: double.infinity,
height: 55.0,
//child:Expanded(
child:Card(
color: Color.fromRGBO(36, 46, 66, 1),
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(35)
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
height: 40.0,
width: 50.0,
decoration: BoxDecoration(
color: Colors.blueAccent,
shape: BoxShape.circle,
border: new Border.all(
color: Colors.blue,
width: 2.5,
),
),
child: Icon(
Icons.calendar_today,
size: 25.0,
color: Colors.white,
),
),
Expanded(
child:
Column(
//mainAxisAlignment: MainAxisAlignment.center,
//mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
//new Row(
// mainAxisSize: MainAxisSize.max,
//children: <Widget>[
new Text(
"From", style: TextStyle(color:Colors.white),
),
new Text(
"01 Jan 2019", style: TextStyle(color:Colors.white),
),
// new Icon(Icons.account_circle)
//style: Theme.of(context).textTheme.body2
],
),
),
Expanded(
child:
Column(
//mainAxisAlignment: MainAxisAlignment.center,
//mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
//new Row(
// mainAxisSize: MainAxisSize.max,
//children: <Widget>[
new Text(
"To", style: TextStyle(color:Colors.white),
),
new Text(
"02 Jan 2019", style: TextStyle(color:Colors.white),
),
// new Icon(Icons.account_circle)
//style: Theme.of(context).textTheme.body2
],
),
),
],
)
),
//)
),
]
),
new Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
buildDynamicList(context)
],
)
这是我称为动态列表的功能。我尝试了很多选择,例如扩展,灵活等都会给我错误。
Widget buildDynamicList(BuildContext context) {
return new Container(
//decoration: new BoxDecoration(border: new Border.all(width: 2.0)),
height:200,
//fit: FlexFit.loose ,
child: ListView.builder(
// shrinkWrap: true,
itemCount: vehicles.length,
itemBuilder: (BuildContext ctxt, int index) {
return new ListView(
children: <Widget>[
new Text("TEE"),
]
);
}
),
);
}
答案 0 :(得分:1)
删除嵌套的listview
,因为它是不必要的:
Widget buildDynamicList(BuildContext context) {
return new Container(
//decoration: new BoxDecoration(border: new Border.all(width: 2.0)),
height:200,
//fit: FlexFit.loose ,
child: ListView.builder(
//shrinkWrap: true,
itemCount: vehicles.length,
itemBuilder: (BuildContext ctxt, int index) {
return Text("TEE"),
}
),
);
}