@@ -27,11 +27,12 @@ class UnknownMapIDError extends Error {
2727 /// Message describing the assertion error.
2828 final Object ? message;
2929
30+ @override
3031 String toString () {
3132 if (message != null ) {
32- return " Unknown map ID $mapId : ${Error .safeToString (message )}" ;
33+ return ' Unknown map ID $mapId : ${Error .safeToString (message )}' ;
3334 }
34- return " Unknown map ID $mapId " ;
35+ return ' Unknown map ID $mapId ' ;
3536 }
3637}
3738
@@ -48,19 +49,20 @@ class UnknownMapIDError extends Error {
4849class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
4950 // Keep a collection of id -> channel
5051 // Every method call passes the int mapId
51- final Map <int , MethodChannel > _channels = {};
52+ final Map <int , MethodChannel > _channels = < int , MethodChannel > {};
5253
5354 /// Accesses the MethodChannel associated to the passed mapId.
5455 MethodChannel channel (int mapId) {
55- MethodChannel ? channel = _channels[mapId];
56+ final MethodChannel ? channel = _channels[mapId];
5657 if (channel == null ) {
5758 throw UnknownMapIDError (mapId);
5859 }
5960 return channel;
6061 }
6162
6263 // 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 >> {};
6466
6567 /// Returns the channel for [mapId] , creating it if it doesn't already exist.
6668 @visibleForTesting
@@ -77,7 +79,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
7779
7880 @override
7981 Future <void > init (int mapId) {
80- MethodChannel channel = ensureChannelInitialized (mapId);
82+ final MethodChannel channel = ensureChannelInitialized (mapId);
8183 return channel.invokeMethod <void >('map#waitForMap' );
8284 }
8385
@@ -91,12 +93,13 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
9193 //
9294 // It is a `broadcast` because multiple controllers will connect to
9395 // 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 ();
9698
9799 // 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);
100103
101104 @override
102105 Stream <CameraMoveStartedEvent > onCameraMoveStarted ({required int mapId}) {
@@ -180,52 +183,52 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
180183 case 'marker#onTap' :
181184 _mapEventStreamController.add (MarkerTapEvent (
182185 mapId,
183- MarkerId (call.arguments['markerId' ]),
186+ MarkerId (call.arguments['markerId' ] as String ),
184187 ));
185188 break ;
186189 case 'marker#onDragStart' :
187190 _mapEventStreamController.add (MarkerDragStartEvent (
188191 mapId,
189192 LatLng .fromJson (call.arguments['position' ])! ,
190- MarkerId (call.arguments['markerId' ]),
193+ MarkerId (call.arguments['markerId' ] as String ),
191194 ));
192195 break ;
193196 case 'marker#onDrag' :
194197 _mapEventStreamController.add (MarkerDragEvent (
195198 mapId,
196199 LatLng .fromJson (call.arguments['position' ])! ,
197- MarkerId (call.arguments['markerId' ]),
200+ MarkerId (call.arguments['markerId' ] as String ),
198201 ));
199202 break ;
200203 case 'marker#onDragEnd' :
201204 _mapEventStreamController.add (MarkerDragEndEvent (
202205 mapId,
203206 LatLng .fromJson (call.arguments['position' ])! ,
204- MarkerId (call.arguments['markerId' ]),
207+ MarkerId (call.arguments['markerId' ] as String ),
205208 ));
206209 break ;
207210 case 'infoWindow#onTap' :
208211 _mapEventStreamController.add (InfoWindowTapEvent (
209212 mapId,
210- MarkerId (call.arguments['markerId' ]),
213+ MarkerId (call.arguments['markerId' ] as String ),
211214 ));
212215 break ;
213216 case 'polyline#onTap' :
214217 _mapEventStreamController.add (PolylineTapEvent (
215218 mapId,
216- PolylineId (call.arguments['polylineId' ]),
219+ PolylineId (call.arguments['polylineId' ] as String ),
217220 ));
218221 break ;
219222 case 'polygon#onTap' :
220223 _mapEventStreamController.add (PolygonTapEvent (
221224 mapId,
222- PolygonId (call.arguments['polygonId' ]),
225+ PolygonId (call.arguments['polygonId' ] as String ),
223226 ));
224227 break ;
225228 case 'circle#onTap' :
226229 _mapEventStreamController.add (CircleTapEvent (
227230 mapId,
228- CircleId (call.arguments['circleId' ]),
231+ CircleId (call.arguments['circleId' ] as String ),
229232 ));
230233 break ;
231234 case 'map#onTap' :
@@ -243,17 +246,17 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
243246 case 'tileOverlay#getTile' :
244247 final Map <TileOverlayId , TileOverlay >? tileOverlaysForThisMap =
245248 _tileOverlays[mapId];
246- final String tileOverlayId = call.arguments['tileOverlayId' ];
249+ final String tileOverlayId = call.arguments['tileOverlayId' ] as String ;
247250 final TileOverlay ? tileOverlay =
248251 tileOverlaysForThisMap? [TileOverlayId (tileOverlayId)];
249- TileProvider ? tileProvider = tileOverlay? .tileProvider;
252+ final TileProvider ? tileProvider = tileOverlay? .tileProvider;
250253 if (tileProvider == null ) {
251254 return TileProvider .noTile.toJson ();
252255 }
253256 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 ? ,
257260 );
258261 return tile.toJson ();
259262 default :
@@ -330,7 +333,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
330333 }) {
331334 final Map <TileOverlayId , TileOverlay >? currentTileOverlays =
332335 _tileOverlays[mapId];
333- Set <TileOverlay > previousSet = currentTileOverlays != null
336+ final Set <TileOverlay > previousSet = currentTileOverlays != null
334337 ? currentTileOverlays.values.toSet ()
335338 : < TileOverlay > {};
336339 final TileOverlayUpdates updates =
@@ -380,9 +383,9 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
380383 }) async {
381384 final List <dynamic > successAndError = (await channel (mapId)
382385 .invokeMethod <List <dynamic >>('map#setStyle' , mapStyle))! ;
383- final bool success = successAndError[0 ];
386+ final bool success = successAndError[0 ] as bool ;
384387 if (! success) {
385- throw MapStyleException (successAndError[1 ]);
388+ throw MapStyleException (successAndError[1 ] as String );
386389 }
387390 }
388391
@@ -418,7 +421,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
418421 final List <dynamic > latLng = (await channel (mapId)
419422 .invokeMethod <List <dynamic >>(
420423 'map#getLatLng' , screenCoordinate.toJson ()))! ;
421- return LatLng (latLng[0 ], latLng[1 ]);
424+ return LatLng (latLng[0 ] as double , latLng[1 ] as double );
422425 }
423426
424427 @override
0 commit comments