form_bloc icon indicating copy to clipboard operation
form_bloc copied to clipboard

Listening on SwitchFieldBlocBuilder changes

Open DamnMiri opened this issue 4 years ago • 3 comments

Hi,

I can get OnTap or OnChanged and many others on TextFieldBlocBuilder, but nothing is available for SwitchFieldBlocBuilder to listen if the switch was pressed.

I tried wrapping into a GestureDetector but the switch press does not fire its events, only pressing on the label works. Not very useful.

DamnMiri avatar Aug 04 '20 12:08 DamnMiri

Hi, I include it later, what are you trying to do? for now you can listen to the field bloc

 formBloc.booleanField.onValueChanges(
      onData: (previous, current) async* {
        if (current.value) {
          // ,,,
        } else {
         //...
        }
      },
    );

GiancarloCode avatar Aug 04 '20 18:08 GiancarloCode

Show an additional TextFieldBlocBuilder after activating the switch.

Something really simple like this.


example

I guess i can use a normal switch and fetch the value later during OnSubmitting, but i was wondering why at least OnChanged was not present in the SwitchFieldBlocBuilder.

DamnMiri avatar Aug 05 '20 01:08 DamnMiri

hi ,this is my issue, can you help?

haidvams avatar Feb 17 '21 04:02 haidvams