按下每个卡片视图上的Listview Textformfield按下按钮中的每个项目值,即可将其发送到服务器

时间:2019-09-07 09:05:19

标签: flutter flutter-layout flutter-dependencies

我在列表视图中调用了一个api,它的显示如下,我需要在每个字段中输入值并分别发送到服务器。

https://imgur.com/dawTkBf

在此处创建列表视图。

                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));
                }

0 个答案:

没有答案