Я пытаюсь реализовать игрока, используя шаблон BLO C. Когда я меняю состояние в методе mapEventToState (), виджет BlocBulder () не обновляется должным образом.
Это PlayerBlo c: -
class PlayerBloc extends Bloc<PlayerEvent, PlayerState> {
@override
get initialState => PlayerState.Initialized;
@override
Stream<PlayerState> mapEventToState(PlayerEvent event) async* {
if (event is InitialLoad) {
yield PlayerState.Initialized;
} else if (event is PlayStation) {
yield PlayerState.Playing;
} else if (event is StationPlaying) {
yield PlayerState.Playing;
} else if (event is StationStopped) {
yield PlayerState.Stopped;
} else {
yield PlayerState.Stopped;
}
}
}
Это BlocBuilder : -
class PlayerCollapsed extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocBuilder<PlayerBloc, PlayerState>(
bloc: PlayerBloc(),
builder: (BuildContext context, PlayerState state) {
if (state == PlayerState.Initialized) {
print(state);
return Center(child: CircularProgressIndicator());
} else {
return Text("State Updated");
}
},
);
}
}
Любая помощь будет оценена. ?