If FacilityInitial
is a state, then it’s a reason why you couldn’t react to it in mapEventToState
function (in this function you can react only to events, not states). If mapEventToState
is an event (I can’t say for sure, cause you haven’t provided that info) it may conflict with the state class of the same name.
Also, you haven’t provided the code where you creating your bloc instance. To be able to react to events (even on initial events) you are to add this event to bloc. It could look like this:
BlocProvider<FacilityBloc>(
lazy: false,
create: (context) => FacilityBloc(FacilityRepository())..add(FacilityInitialEvent()),
child: Text("My Text"),
)
In the example above I explicitly added FacilityInitialEvent
, so to the bloc be able to handle it. Also, I’ve changed the event name a bit, to avoid name conflict.
CLICK HERE to find out more related problems solutions.