我在列表视图中调用了一个api,它的显示如下,我需要在每个字段中输入值并分别发送到服务器。
在此处创建列表视图。
Widget build(context) {
return ListView.builder(
itemCount: batchStatusListView.length,
itemBuilder: (context, int currentIndex) {
_textcontroller.add(new TextEditingController());
//called cardview here
return batchcard(batchStatusListView[currentIndex], context);
},
);
}
//Cardview initialized here
Widget batchcard(Batchstatus batchstatus, BuildContext context){
return Center(
child: new Card(
margin: EdgeInsets.all(15.0),
color: Colors.lightGreen[100],
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ListTile(
contentPadding: EdgeInsets.all(15.0),
title: Row(
children: <Widget>[
Row(
children: <Widget>[
Text(
batchstatus.batch,
style: TextStyle(
color: Colors.black, fontWeight: FontWeight.bold),
),
],
)
],
),
//called edittext field here.
subtitle: _userContainer(),
),
_buttonContainer(),
],
),
),
);
}
//Button Intialized
Widget _buttonContainer() {
return new Container(
decoration: new BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(6.0),
boxShadow: [
BoxShadow(
color: Color(0xFF6078ea).withOpacity(.3),
offset: Offset(0.0, 8.0),
blurRadius: 15.0)
]
),
child: new MaterialButton(
textColor: Colors.white,
padding: EdgeInsets.all(1.0),
onPressed: (){
},
child: new Text(
'Submit',
style: new TextStyle(fontWeight: FontWeight.bold, fontSize: 17.0),
),
),
margin: EdgeInsets.only(bottom: 15.0));
}
Widget _userContainer(){
return new Container(
padding: EdgeInsets.fromLTRB(7, 15, 7, 0),
child: new TextFormField(
// controller: _textcontroller,
decoration: InputDecoration(
prefixIcon: new Icon(
Icons.input,
color: Colors.blue,
),
labelText: Texts.BATCH_COUNT,
labelStyle: TextStyle(fontSize: 18.0),
border: new OutlineInputBorder(
borderRadius: new BorderRadius.circular(10.0)
),
),
keyboardType: TextInputType.text),
margin: EdgeInsets.only(bottom: 5.0));
}