form_bloc
form_bloc copied to clipboard
context.read() vs context.watch() for FormBloc (flutter_bloc v6.1.0)
When retrieving a FormBloc
, which one should I use?
read()
won't rebuild the widget on state changes (equivalent to Provider.of(context, listen: false)
I guess) and shouldn't be called in the build
method of a widget.
watch()
will rebuild the widget on state changes (equivalent to Provider.of(context)
) and should be called in the build
method of a widget.
Which one is best for the form_bloc
package?
https://github.com/GiancarloCode/form_bloc/pull/312#issuecomment-1164240179