@@ -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}) {
@@ -180,52 +183,52 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
180
183
case 'marker#onTap' :
181
184
_mapEventStreamController.add (MarkerTapEvent (
182
185
mapId,
183
- MarkerId (call.arguments['markerId' ]),
186
+ MarkerId (call.arguments['markerId' ] as String ),
184
187
));
185
188
break ;
186
189
case 'marker#onDragStart' :
187
190
_mapEventStreamController.add (MarkerDragStartEvent (
188
191
mapId,
189
192
LatLng .fromJson (call.arguments['position' ])! ,
190
- MarkerId (call.arguments['markerId' ]),
193
+ MarkerId (call.arguments['markerId' ] as String ),
191
194
));
192
195
break ;
193
196
case 'marker#onDrag' :
194
197
_mapEventStreamController.add (MarkerDragEvent (
195
198
mapId,
196
199
LatLng .fromJson (call.arguments['position' ])! ,
197
- MarkerId (call.arguments['markerId' ]),
200
+ MarkerId (call.arguments['markerId' ] as String ),
198
201
));
199
202
break ;
200
203
case 'marker#onDragEnd' :
201
204
_mapEventStreamController.add (MarkerDragEndEvent (
202
205
mapId,
203
206
LatLng .fromJson (call.arguments['position' ])! ,
204
- MarkerId (call.arguments['markerId' ]),
207
+ MarkerId (call.arguments['markerId' ] as String ),
205
208
));
206
209
break ;
207
210
case 'infoWindow#onTap' :
208
211
_mapEventStreamController.add (InfoWindowTapEvent (
209
212
mapId,
210
- MarkerId (call.arguments['markerId' ]),
213
+ MarkerId (call.arguments['markerId' ] as String ),
211
214
));
212
215
break ;
213
216
case 'polyline#onTap' :
214
217
_mapEventStreamController.add (PolylineTapEvent (
215
218
mapId,
216
- PolylineId (call.arguments['polylineId' ]),
219
+ PolylineId (call.arguments['polylineId' ] as String ),
217
220
));
218
221
break ;
219
222
case 'polygon#onTap' :
220
223
_mapEventStreamController.add (PolygonTapEvent (
221
224
mapId,
222
- PolygonId (call.arguments['polygonId' ]),
225
+ PolygonId (call.arguments['polygonId' ] as String ),
223
226
));
224
227
break ;
225
228
case 'circle#onTap' :
226
229
_mapEventStreamController.add (CircleTapEvent (
227
230
mapId,
228
- CircleId (call.arguments['circleId' ]),
231
+ CircleId (call.arguments['circleId' ] as String ),
229
232
));
230
233
break ;
231
234
case 'map#onTap' :
@@ -243,17 +246,17 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
243
246
case 'tileOverlay#getTile' :
244
247
final Map <TileOverlayId , TileOverlay >? tileOverlaysForThisMap =
245
248
_tileOverlays[mapId];
246
- final String tileOverlayId = call.arguments['tileOverlayId' ];
249
+ final String tileOverlayId = call.arguments['tileOverlayId' ] as String ;
247
250
final TileOverlay ? tileOverlay =
248
251
tileOverlaysForThisMap? [TileOverlayId (tileOverlayId)];
249
- TileProvider ? tileProvider = tileOverlay? .tileProvider;
252
+ final TileProvider ? tileProvider = tileOverlay? .tileProvider;
250
253
if (tileProvider == null ) {
251
254
return TileProvider .noTile.toJson ();
252
255
}
253
256
final Tile tile = await tileProvider.getTile (
254
- call.arguments['x' ],
255
- call.arguments['y' ],
256
- call.arguments['zoom' ],
257
+ call.arguments['x' ] as int ,
258
+ call.arguments['y' ] as int ,
259
+ call.arguments['zoom' ] as int ? ,
257
260
);
258
261
return tile.toJson ();
259
262
default :
@@ -330,7 +333,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
330
333
}) {
331
334
final Map <TileOverlayId , TileOverlay >? currentTileOverlays =
332
335
_tileOverlays[mapId];
333
- Set <TileOverlay > previousSet = currentTileOverlays != null
336
+ final Set <TileOverlay > previousSet = currentTileOverlays != null
334
337
? currentTileOverlays.values.toSet ()
335
338
: < TileOverlay > {};
336
339
final TileOverlayUpdates updates =
@@ -380,9 +383,9 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
380
383
}) async {
381
384
final List <dynamic > successAndError = (await channel (mapId)
382
385
.invokeMethod <List <dynamic >>('map#setStyle' , mapStyle))! ;
383
- final bool success = successAndError[0 ];
386
+ final bool success = successAndError[0 ] as bool ;
384
387
if (! success) {
385
- throw MapStyleException (successAndError[1 ]);
388
+ throw MapStyleException (successAndError[1 ] as String );
386
389
}
387
390
}
388
391
@@ -418,7 +421,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
418
421
final List <dynamic > latLng = (await channel (mapId)
419
422
.invokeMethod <List <dynamic >>(
420
423
'map#getLatLng' , screenCoordinate.toJson ()))! ;
421
- return LatLng (latLng[0 ], latLng[1 ]);
424
+ return LatLng (latLng[0 ] as double , latLng[1 ] as double );
422
425
}
423
426
424
427
@override
0 commit comments