Skip to content

Commit 3a35a39

Browse files
committed
fix: access map controls safely in wasm
1 parent bd5ff35 commit 3a35a39

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎packages/google_maps_flutter/google_maps_flutter_web/example/latest/integration_test/google_maps_controller_test.dart‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ void main() {
11471147
await tester.pumpAndSettle();
11481148

11491149
expect(myLocationController.myLocationButton, isNull);
1150-
expect(map.controls[gmaps.ControlPosition.RIGHT_BOTTOM as int].length, equals(0));
1150+
expect(map.getControlsAt(gmaps.ControlPosition.RIGHT_BOTTOM).length, equals(0));
11511151
});
11521152

11531153
testWidgets('initializes with my location & display my location button', (
@@ -1182,7 +1182,7 @@ void main() {
11821182
controller.init();
11831183
await tester.pumpAndSettle();
11841184

1185-
expect(map.controls[gmaps.ControlPosition.RIGHT_BOTTOM as int].length, equals(1));
1185+
expect(map.getControlsAt(gmaps.ControlPosition.RIGHT_BOTTOM).length, equals(1));
11861186
});
11871187

11881188
testWidgets('initializes with my location only', (WidgetTester tester) async {
@@ -1215,7 +1215,7 @@ void main() {
12151215
controller.init();
12161216
await tester.pumpAndSettle();
12171217

1218-
expect(map.controls[gmaps.ControlPosition.RIGHT_BOTTOM as int].length, equals(0));
1218+
expect(map.getControlsAt(gmaps.ControlPosition.RIGHT_BOTTOM).length, equals(0));
12191219
});
12201220
});
12211221
});

‎packages/google_maps_flutter/google_maps_flutter_web/lib/src/my_location.dart‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ class MyLocationController {
125125
}.toJS,
126126
);
127127
if (myLocationButton != null) {
128-
map.controls[gmaps.ControlPosition.RIGHT_BOTTOM as int].push(myLocationButton!.getButton);
128+
map.getControlsAt(gmaps.ControlPosition.RIGHT_BOTTOM).push(myLocationButton!.getButton);
129129
}
130130
}
131131

132132
/// Remove my location button from map
133133
void removeMyLocationButton(gmaps.Map map) {
134134
if (myLocationButton != null) {
135-
map.controls[gmaps.ControlPosition.RIGHT_BOTTOM as int].pop();
135+
map.getControlsAt(gmaps.ControlPosition.RIGHT_BOTTOM).pop();
136136
myLocationButton = null;
137137
}
138138
_dragEndListener?.remove();

0 commit comments

Comments
 (0)