Skip to content

Commit

Permalink
fix: rebuilding the CustomMapStyler correctly wires it to the MapStyl…
Browse files Browse the repository at this point in the history
…eButton
  • Loading branch information
smallTrogdor authored Nov 13, 2024
1 parent 368621a commit 6ff2a70
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,6 @@ See [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).

* When selecting POIs programmatically with the `RokasPOIController`, one can only select from the POIs that are loaded in the tile source, meaning that trying to select a POI at a very distant place will not be possible. The workaround would be to first move to the geo coordinate and then select the POI.

### Known Bugs

* The [SBBMapStyleSwitchButton] is not working when the [SBBMap] is rebuild and the passed in [SBBMapStyler] is not preserved in the state. Make sure to keep the styler in your state.


[Journey Maps API]: (https://developer.sbb.ch/apis/journey-maps/information)

Expand Down
2 changes: 1 addition & 1 deletion lib/src/sbb_map/sbb_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ class _SBBMapState extends State<SBBMap> {
if (oldWidget.mapStyler != widget.mapStyler) {
oldWidget.mapStyler.removeListener(_setStyleLoadedFalse);
widget.mapStyler.addListener(_setStyleLoadedFalse);
oldWidget.mapStyler.dispose();
}
super.didUpdateWidget(oldWidget);
}
Expand Down Expand Up @@ -330,7 +331,6 @@ class _SBBMapState extends State<SBBMap> {

_buildUserControls() {
return SBBMapStyleContainer(
key: UniqueKey(),
child: SBBMapUiContainer(
mapStyler: widget.mapStyler,
mapLocator: _mapLocator,
Expand Down
6 changes: 4 additions & 2 deletions lib/src/sbb_map_style/sbb_custom_map_styler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ class SBBCustomMapStyler with ChangeNotifier implements SBBMapStyler {
_aerialStyle == other._aerialStyle &&
_preAerialStyle == other._preAerialStyle &&
_isDarkMode == other._isDarkMode &&
_isAerialStyle == other._isAerialStyle;
_isAerialStyle == other._isAerialStyle &&
hasListeners == other.hasListeners;

@override
int get hashCode =>
Expand All @@ -97,5 +98,6 @@ class SBBCustomMapStyler with ChangeNotifier implements SBBMapStyler {
_aerialStyle.hashCode ^
_preAerialStyle.hashCode ^
_isDarkMode.hashCode ^
_isAerialStyle.hashCode;
_isAerialStyle.hashCode ^
hasListeners.hashCode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@ class SBBMapUiContainer extends InheritedWidget {
}

@override
bool updateShouldNotify(SBBMapUiContainer oldWidget) => false;
bool updateShouldNotify(SBBMapUiContainer oldWidget) =>
mapStyler != oldWidget.mapStyler ||
mapLocator != oldWidget.mapLocator ||
mapFloorController != oldWidget.mapFloorController;
}

0 comments on commit 6ff2a70

Please sign in to comment.