flutter_form_builder icon indicating copy to clipboard operation
flutter_form_builder copied to clipboard

Form Value Builder Widget To Update UI

Open BLaZeKiLL opened this issue 3 years ago • 3 comments

A workaround is to have the form builder inside a stateful widget but a builder widget would be more convenient

FormBuilder(
  key: form,
  initialValue: {'dp': <SOME_VALUE>},
  child: Column(
    children: [
      FormBuilderValue(
        builder: (form_value) => <SOME_WIDGET>
      ),
      DPSelector(name: 'dp')
    ]
  )
)

Current use case that I have is -

  • I have a profile picture selector as part of the form
  • I want to display the currently selected picture next to the username

For now I am using a stateful widget to handle this.

I'd be happy to work on a pull request for this if it seems fruitful.

BLaZeKiLL avatar Feb 14 '22 17:02 BLaZeKiLL

Sorry, but I could not understand. Are you trying to show/hide fields dynamically? In such case, registerField and removeInternalFieldValue from formKey currentState does not satisfy your situation?

WilliamCunhaCardoso avatar Feb 23 '22 15:02 WilliamCunhaCardoso

@WilliamCunhaCardoso Is there an example or any documentation for what you're referring? (am trying to show/hide fields dynamically) It would be helpful for any first timers like me. Appreciate and thanks in advance.

dev-thinks avatar Mar 31 '22 05:03 dev-thinks

@WilliamCunhaCardoso Is there an example or any documentation for what you're referring? (am trying to show/hide fields dynamically) It would be helpful for any first timers like me. Appreciate and thanks in advance.

Unfortunately, no :(

But I wish to do one. Actually, I am with limited time due to my job, so, till now I could not be able to give such help.

Actually, here in my project I am showing and hiding fields with Visibility()

WilliamCunhaCardoso avatar Mar 31 '22 13:03 WilliamCunhaCardoso

@BLaZeKiLL I don't understand your question. What do you need? Show a form field value in another widget?

deandreamatias avatar Aug 19 '22 08:08 deandreamatias

This is similar too 2 way binding in angular,

Suppose I have a text input field and a plain old text widget. I would like to have the value from the text field be reflected in the text widget without needing to submit the form

So if we have a builder widget that returns the forms current value we can have a text widget in side the builder reading the form value and displaying it.

Anytime the text input field is updated the builder widget would rebuild with the updated value

BLaZeKiLL avatar Aug 19 '22 09:08 BLaZeKiLL

@BLaZeKiLL Ok, maybe with formKey.currentState.instantValues['fieldName'].value can be access to instant value of field and used in widget that you want

deandreamatias avatar Aug 19 '22 10:08 deandreamatias

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Sep 19 '22 02:09 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Sep 27 '22 02:09 github-actions[bot]