在Flutter中通过Formfield传递初始值(文件图像)?

时间:2019-10-15 07:53:14

标签: flutter

在我的应用中,一种选择是编辑同时包含文本和图像的表单?

要编辑文本,我正在使用 TextFormField 并将先前的值传递给initialValue类,并且工作正常吗?

对于图像,我正在使用 FormField ,并且还通过使用FormField的initialValue类传递了先前的图像(文件图像),但是初始/先前的图像没有反映在我的表单中? >

那么,我在这里寻找解决方法吗?

这是示例代码

 // Code is quite bigger, so i am adding the bits & pieces related to problem. DO not concentrate on syntax 

 final _form = GlobalKey<FormState>();

 void _save(){
 final isValid = _form.currentState.validate();
    if(!isValid) {
      return;
    }
    _formSubmit.currentState.save();
 // some code

 void didchangedepndencies(){
 //code to pass the initial values


 // widget(build)Scaffold & other are added 

 Form(
              key: _form,
              child: ListView(
              //agian some code

              FormField(
                                initialValue: _initValues ['image'],
                                // Image.file is the initial value
                                //This Formfield is having problem, new images are passing fine
                                //builder, validator, onSaved all are included & working fine

                                ),
             TextFormField(
                    initialValue: _initValues['name'],
                    //here inital values are being passed & everything is working well

             TextFormField(
                    initialValue: _initValues['quantity'],
                    //here inital values are being passed & everything is working well

0 个答案:

没有答案