BlocListener
Learn about BlocListener and how it's used by widgets to listen to state changes.
We'll cover the following...
The BlocListener
is another commonly used widget when implementing BLoCs using the flutter_bloc
library. With this widget, we can call a function whenever there’s a change in the state we monitor. The main difference between BlocListener
and BlocBuilder
is that BlocListener
doesn’t return a widget, while BlocBuilder
returns a widget that will be rebuilt every time the state changes.
Basic usage
The BlocListener
widget takes a listener()
function and an optional bloc
parameter. The listener()
function is automatically ...