我在函数内有一个文本框:
Container header(int position) {
return Container(
height: 50.0,
decoration: new BoxDecoration(
border: new Border.all(color: Colors.black, width: 0.75)),
padding:
new EdgeInsets.only(top: 7.5, bottom: 7.5, left: 20.0, right: 20.0),
child: new Container(
child: new Row(
children: <Widget>[
//MEAL TF
mealNameTextField(position),
//TIME TF
timeTextField(),
],
),
),
);}
mealNameTextField():
Container mealNameTextField(int position) {
return new Container(
width: 160.0,
alignment: Alignment.centerLeft,
child: new TextField(
textAlign: TextAlign.center,
decoration: InputDecoration(
contentPadding: EdgeInsets.all(8.0),
hintText: "Meal Name #${position.toString()}",
border: border(),
hintStyle: new TextStyle(fontSize: 16.0),
fillColor: colorBackgroundTable,
filled: true,
),
));}
此文本字段(标头函数)在listView中:
child: new ListView.builder(
controller: scrollController,
physics: NeverScrollableScrollPhysics(),
scrollDirection: Axis.horizontal,
padding: EdgeInsets.only(top: 15.0, left: 20.0),
itemCount: numMeals,
key: key,
itemBuilder: (BuildContext context, int position) => Padding(
padding: new EdgeInsets.only(right: 20.0),
child: new Container(
width: 320.0,
color: Colors.blueAccent,
child: new ListView(
children: <Widget>[
new Container(
height: double.maxFinite,
color: colorBackground,
child: new ListView(
children: <Widget>[
header(position),
bodyListFood(),
new SizedBox(height: 12.0),
buttonAddFood(),
new SizedBox(height: 12.0),
nutriInfo(),
new SizedBox(height: 24.0)
],
))
],
),
但是,当我更改文本字段的de值时,会出现以下错误: https://i.imgur.com/oGhOwcz.png
仅当texfield位于列表视图中时,才会发生此错误。在它外面,效果很好。