form_bloc icon indicating copy to clipboard operation
form_bloc copied to clipboard

context.read() vs context.watch() for FormBloc (flutter_bloc v6.1.0)

Open Reprevise opened this issue 3 years ago • 1 comments

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?

Reprevise avatar Nov 08 '20 12:11 Reprevise

https://github.com/GiancarloCode/form_bloc/pull/312#issuecomment-1164240179

vasilich6107 avatar Mar 11 '23 18:03 vasilich6107