@@ -27,11 +27,12 @@ class UnknownMapIDError extends Error {
27
27
/// Message describing the assertion error.
28
28
final Object ? message;
29
29
30
+ @override
30
31
String toString () {
31
32
if (message != null ) {
32
- return " Unknown map ID $mapId : ${Error .safeToString (message )}" ;
33
+ return ' Unknown map ID $mapId : ${Error .safeToString (message )}' ;
33
34
}
34
- return " Unknown map ID $mapId " ;
35
+ return ' Unknown map ID $mapId ' ;
35
36
}
36
37
}
37
38
@@ -48,19 +49,20 @@ class UnknownMapIDError extends Error {
48
49
class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
49
50
// Keep a collection of id -> channel
50
51
// Every method call passes the int mapId
51
- final Map <int , MethodChannel > _channels = {};
52
+ final Map <int , MethodChannel > _channels = < int , MethodChannel > {};
52
53
53
54
/// Accesses the MethodChannel associated to the passed mapId.
54
55
MethodChannel channel (int mapId) {
55
- MethodChannel ? channel = _channels[mapId];
56
+ final MethodChannel ? channel = _channels[mapId];
56
57
if (channel == null ) {
57
58
throw UnknownMapIDError (mapId);
58
59
}
59
60
return channel;
60
61
}
61
62
62
63
// Keep a collection of mapId to a map of TileOverlays.
63
- final Map <int , Map <TileOverlayId , TileOverlay >> _tileOverlays = {};
64
+ final Map <int , Map <TileOverlayId , TileOverlay >> _tileOverlays =
65
+ < int , Map <TileOverlayId , TileOverlay >> {};
64
66
65
67
/// Returns the channel for [mapId] , creating it if it doesn't already exist.
66
68
@visibleForTesting
@@ -77,7 +79,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
77
79
78
80
@override
79
81
Future <void > init (int mapId) {
80
- MethodChannel channel = ensureChannelInitialized (mapId);
82
+ final MethodChannel channel = ensureChannelInitialized (mapId);
81
83
return channel.invokeMethod <void >('map#waitForMap' );
82
84
}
83
85
@@ -91,12 +93,13 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
91
93
//
92
94
// It is a `broadcast` because multiple controllers will connect to
93
95
// different stream views of this Controller.
94
- final StreamController <MapEvent > _mapEventStreamController =
95
- StreamController <MapEvent >.broadcast ();
96
+ final StreamController <MapEvent < Object ?> > _mapEventStreamController =
97
+ StreamController <MapEvent < Object ?> >.broadcast ();
96
98
97
99
// Returns a filtered view of the events in the _controller, by mapId.
98
- Stream <MapEvent > _events (int mapId) =>
99
- _mapEventStreamController.stream.where ((event) => event.mapId == mapId);
100
+ Stream <MapEvent <Object ?>> _events (int mapId) =>
101
+ _mapEventStreamController.stream
102
+ .where ((MapEvent <Object ?> event) => event.mapId == mapId);
100
103
101
104
@override
102
105
Stream <CameraMoveStartedEvent > onCameraMoveStarted ({required int mapId}) {
@@ -185,52 +188,52 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
185
188
case 'marker#onTap' :
186
189
_mapEventStreamController.add (MarkerTapEvent (
187
190
mapId,
188
- MarkerId (call.arguments['markerId' ]),
191
+ MarkerId (call.arguments['markerId' ] as String ),
189
192
));
190
193
break ;
191
194
case 'marker#onDragStart' :
192
195
_mapEventStreamController.add (MarkerDragStartEvent (
193
196
mapId,
194
197
LatLng .fromJson (call.arguments['position' ])! ,
195
- MarkerId (call.arguments['markerId' ]),
198
+ MarkerId (call.arguments['markerId' ] as String ),
196
199
));
197
200
break ;
198
201
case 'marker#onDrag' :
199
202
_mapEventStreamController.add (MarkerDragEvent (
200
203
mapId,
201
204
LatLng .fromJson (call.arguments['position' ])! ,
202
- MarkerId (call.arguments['markerId' ]),
205
+ MarkerId (call.arguments['markerId' ] as String ),
203
206
));
204
207
break ;
205
208
case 'marker#onDragEnd' :
206
209
_mapEventStreamController.add (MarkerDragEndEvent (
207
210
mapId,
208
211
LatLng .fromJson (call.arguments['position' ])! ,
209
- MarkerId (call.arguments['markerId' ]),
212
+ MarkerId (call.arguments['markerId' ] as String ),
210
213
));
211
214
break ;
212
215
case 'infoWindow#onTap' :
213
216
_mapEventStreamController.add (InfoWindowTapEvent (
214
217
mapId,
215
- MarkerId (call.arguments['markerId' ]),
218
+ MarkerId (call.arguments['markerId' ] as String ),
216
219
));
217
220
break ;
218
221
case 'polyline#onTap' :
219
222
_mapEventStreamController.add (PolylineTapEvent (
220
223
mapId,
221
- PolylineId (call.arguments['polylineId' ]),
224
+ PolylineId (call.arguments['polylineId' ] as String ),
222
225
));
223
226
break ;
224
227
case 'polygon#onTap' :
225
228
_mapEventStreamController.add (PolygonTapEvent (
226
229
mapId,
227
- PolygonId (call.arguments['polygonId' ]),
230
+ PolygonId (call.arguments['polygonId' ] as String ),
228
231
));
229
232
break ;
230
233
case 'circle#onTap' :
231
234
_mapEventStreamController.add (CircleTapEvent (
232
235
mapId,
233
- CircleId (call.arguments['circleId' ]),
236
+ CircleId (call.arguments['circleId' ] as String ),
234
237
));
235
238
break ;
236
239
case 'groundOverlay#onTap' :
@@ -254,17 +257,17 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
254
257
case 'tileOverlay#getTile' :
255
258
final Map <TileOverlayId , TileOverlay >? tileOverlaysForThisMap =
256
259
_tileOverlays[mapId];
257
- final String tileOverlayId = call.arguments['tileOverlayId' ];
260
+ final String tileOverlayId = call.arguments['tileOverlayId' ] as String ;
258
261
final TileOverlay ? tileOverlay =
259
262
tileOverlaysForThisMap? [TileOverlayId (tileOverlayId)];
260
- TileProvider ? tileProvider = tileOverlay? .tileProvider;
263
+ final TileProvider ? tileProvider = tileOverlay? .tileProvider;
261
264
if (tileProvider == null ) {
262
265
return TileProvider .noTile.toJson ();
263
266
}
264
267
final Tile tile = await tileProvider.getTile (
265
- call.arguments['x' ],
266
- call.arguments['y' ],
267
- call.arguments['zoom' ],
268
+ call.arguments['x' ] as int ,
269
+ call.arguments['y' ] as int ,
270
+ call.arguments['zoom' ] as int ? ,
268
271
);
269
272
return tile.toJson ();
270
273
default :
@@ -341,7 +344,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
341
344
}) {
342
345
final Map <TileOverlayId , TileOverlay >? currentTileOverlays =
343
346
_tileOverlays[mapId];
344
- Set <TileOverlay > previousSet = currentTileOverlays != null
347
+ final Set <TileOverlay > previousSet = currentTileOverlays != null
345
348
? currentTileOverlays.values.toSet ()
346
349
: < TileOverlay > {};
347
350
final TileOverlayUpdates updates =
@@ -403,9 +406,9 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
403
406
}) async {
404
407
final List <dynamic > successAndError = (await channel (mapId)
405
408
.invokeMethod <List <dynamic >>('map#setStyle' , mapStyle))! ;
406
- final bool success = successAndError[0 ];
409
+ final bool success = successAndError[0 ] as bool ;
407
410
if (! success) {
408
- throw MapStyleException (successAndError[1 ]);
411
+ throw MapStyleException (successAndError[1 ] as String );
409
412
}
410
413
}
411
414
@@ -441,7 +444,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
441
444
final List <dynamic > latLng = (await channel (mapId)
442
445
.invokeMethod <List <dynamic >>(
443
446
'map#getLatLng' , screenCoordinate.toJson ()))! ;
444
- return LatLng (latLng[0 ], latLng[1 ]);
447
+ return LatLng (latLng[0 ] as double , latLng[1 ] as double );
445
448
}
446
449
447
450
@override
0 commit comments