flutter_form_builder icon indicating copy to clipboard operation
flutter_form_builder copied to clipboard

Is there a way to show/hide a form field according to value of another field?

Open wyxcoder opened this issue 5 years ago • 3 comments

thanks

wyxcoder avatar Apr 09 '21 22:04 wyxcoder

you can do this using check _formkey current state and _formkey should not be as final and in the form change you have to setState

var _formKey = GlobalKey<FormBuilderState>();

FormBuilder(
            key: _formKey,
            onChanged: (){
              setState(() {
              });
            },
            child: Column(
              children: [
                _generateQuestions(context, widget.questions),
              ],
            ));

bool canShow = _formKey.currentState.fields['gender'].value.toString() == 'male';

if this boolean true you can show your component. it perfectly works for me.

yathu avatar Apr 27 '21 09:04 yathu

This comments help to solve problem @wyxcoder ? If yes, can close this issue

deandreamatias avatar Jun 10 '22 12:06 deandreamatias

Due to lack of response, I will close this issue. If the bug still exists, feel free to open a new issue

deandreamatias avatar Jun 26 '22 14:06 deandreamatias