I have the problem that when I start the application my map appears one way and then on passing from the bottomnavigatioBar tab it gets completely redrawn when I return.
I think it is a problem with the block and state map.
I need to know what the solution would be so that it does not get redrawn, that is, if I leave the map in a position and step in the tab, when I come back, it looks where I left it.
my map bloc:
class MapaBloc extends Bloc<MapaEvent, MapaState> {
MapaBloc() : super(new MapaState());
GoogleMapController _mapController;
void initMapa(GoogleMapController controller) {
{
this._mapController = controller;
this._mapController.setMapStyle(jsonEncode(testMapTheme));
add(OnMapaListo());
}
}
void moverCamara(LatLng destino) {
final cameraUpdate = CameraUpdate.newLatLng(destino);
this._mapController?.animateCamera(cameraUpdate);
}
@override
Stream<MapaState> mapEventToState(MapaEvent event) async* {
if (event is OnMapaListo) {
yield state.copyWith(mapaListo: true);
}
}
}
my map event:
@immutable
abstract class MapaEvent {}
class OnMapaListo extends MapaEvent {}
my map state
@immutable
class MapaState {
final bool mapaListo;
MapaState({this.mapaListo = false});
MapaState copyWith({bool mapaListo}) =>
MapaState(mapaListo: mapaListo ?? this.mapaListo);
}