Skip to content

Commit

Permalink
Fix some map events not propagating to flutter side due to excessive …
Browse files Browse the repository at this point in the history
…re-subscribtions (#805)
  • Loading branch information
evil159 authored Dec 11, 2024
1 parent 9a97733 commit d887f9e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/src/map_events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class _MapEvents {
OnStyleImageUnusedListener? _onStyleImageUnusedListener;
OnResourceRequestListener? _onResourceRequestListener;
late final MethodChannel _channel;
List<_MapEvent> _subscribedEventTypes = [];
List<_MapEvent> subscribedEventTypes = [];

List<_MapEvent> get eventTypes {
final listenersMap = {
Expand Down Expand Up @@ -54,15 +54,15 @@ final class _MapEvents {
void updateSubscriptions() {
final newEventTypes = eventTypes;

if (listEquals(newEventTypes, _subscribedEventTypes)) {
if (listEquals(newEventTypes, subscribedEventTypes)) {
return;
}

// let the native side know which events we are interested in
_channel.invokeMethod(
"subscribeToEvents", newEventTypes.map((e) => e.index).toList());

_subscribedEventTypes = newEventTypes;
subscribedEventTypes = newEventTypes;
}

void dispose() {
Expand Down
1 change: 1 addition & 0 deletions lib/src/map_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class _MapWidgetState extends State<MapWidget> {
'mapboxPluginVersion': '2.5.0-rc.1',
'eventTypes': _events.eventTypes.map((e) => e.index).toList(),
};
_events.subscribedEventTypes = _events.eventTypes;

return _mapboxMapsPlatform.buildView(widget.androidHostingMode,
creationParams, onPlatformViewCreated, widget.gestureRecognizers,
Expand Down

0 comments on commit d887f9e

Please sign in to comment.