I have the following piece of code:
class VehicleLoaded extends VehicleState {
final Vehicle vehicle;
VehicleLoaded({this.vehicle}) : super([vehicle]);
}
Is possible to get the variable vehicle without the need for a _BlocBuilder_?
Thanks
Hi @esfomeado 馃憢
Thanks for opening an issue!
You can access the stream of bloc states via the state property like:
bloc.state.listen((state) {
// Do stuff with state
});
You can also access it from the UI using BlocListener:
BlocListener(
bloc: bloc,
listener: (BuildContext context, State state) {
// Do stuff with state
}
child: ...
)
Alternatively, if you just want to know the current state of the bloc you can use the currentState property.
final state = bloc.currentState;
// Do stuff with state
Hope that helps! 馃憤
Most helpful comment
Hi @esfomeado 馃憢
Thanks for opening an issue!
You can access the stream of bloc states via the
stateproperty like:You can also access it from the UI using
BlocListener:Alternatively, if you just want to know the current state of the bloc you can use the
currentStateproperty.Hope that helps! 馃憤