Skip to content

Commit 18f4818

Browse files
authored
Ignore event subsription updates while platform view is creating (#724)
1 parent a0d2f1f commit 18f4818

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ onCameraChangeListener(CameraChangedEventData data) {
1212
* Print to console native Maps SDK logs in debug configuration.
1313
Logs are proxied only in debug configuration and can be disabled completely by passing environment flag `MAPBOX_LOG_DEBUG` with false value.
1414
* Fix rare crash in `Snapshotter`. The crash could happen when creating/destroying multiple instances of `Snapshotter` in succession.
15-
* Fix crash in Snapshotter when GlyphsRasterizationMode is specified in MapSnapshotOptions.
15+
* Fix a crash that occurs when the widget state is updated before the platform view is created.
16+
* Fix a crash in Snapshotter when GlyphsRasterizationMode is specified in MapSnapshotOptions.
1617

1718
# 2.3.0
1819

lib/src/map_widget.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class _MapWidgetState extends State<MapWidget> {
176176
late final BinaryMessenger _binaryMessenger =
177177
ProxyBinaryMessenger(suffix: _suffix.toString());
178178
late final _MapEvents _events;
179-
179+
bool _platformViewCreated = false;
180180
MapboxMap? mapboxMap;
181181

182182
@override
@@ -217,7 +217,10 @@ class _MapWidgetState extends State<MapWidget> {
217217
super.didUpdateWidget(oldWidget);
218218

219219
_updateEventListeners();
220-
_events.updateSubscriptions();
220+
221+
if (_platformViewCreated) {
222+
_events.updateSubscriptions();
223+
}
221224
}
222225

223226
void _updateEventListeners() {
@@ -249,5 +252,8 @@ class _MapWidgetState extends State<MapWidget> {
249252
widget.onMapCreated!(controller);
250253
}
251254
mapboxMap = controller;
255+
256+
_events.updateSubscriptions();
257+
_platformViewCreated = true;
252258
}
253259
}

0 commit comments

Comments
 (0)