我需要根据日期选择构建一个动态列表视图,然后我将调用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"),
]
);
}
),
);
}
删除嵌套的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"),
}
),
);
}