@@ -429,96 +429,75 @@ class _GoogleMapState extends State<GoogleMap> {
429
429
@override
430
430
void didUpdateWidget (GoogleMap oldWidget) {
431
431
super .didUpdateWidget (oldWidget);
432
- _updateOptions ();
433
- _updateClusterManagers ();
434
- _updateMarkers ();
435
- _updatePolygons ();
436
- _updatePolylines ();
437
- _updateCircles ();
438
- _updateHeatmaps ();
439
- _updateTileOverlays ();
440
- _updateGroundOverlays ();
432
+
433
+ _refreshStateFromWidget ();
434
+ }
435
+
436
+ Future <void > _refreshStateFromWidget () async {
437
+ final GoogleMapController controller = await _controller.future;
438
+ if (! mounted) {
439
+ return ;
440
+ }
441
+
442
+ _updateOptions (controller);
443
+ _updateClusterManagers (controller);
444
+ _updateMarkers (controller);
445
+ _updatePolygons (controller);
446
+ _updatePolylines (controller);
447
+ _updateCircles (controller);
448
+ _updateHeatmaps (controller);
449
+ _updateTileOverlays (controller);
450
+ _updateGroundOverlays (controller);
441
451
}
442
452
443
- Future < void > _updateOptions () async {
453
+ void _updateOptions (GoogleMapController controller) {
444
454
final MapConfiguration newConfig = _configurationFromMapWidget (widget);
445
455
final MapConfiguration updates = newConfig.diffFrom (_mapConfiguration);
446
456
if (updates.isEmpty) {
447
457
return ;
448
458
}
449
- final GoogleMapController controller = await _controller.future;
450
- if (! mounted) {
451
- return ;
452
- }
459
+
453
460
unawaited (controller._updateMapConfiguration (updates));
454
461
_mapConfiguration = newConfig;
455
462
}
456
463
457
- Future <void > _updateMarkers () async {
458
- final GoogleMapController controller = await _controller.future;
459
- if (! mounted) {
460
- return ;
461
- }
464
+ void _updateMarkers (GoogleMapController controller) {
462
465
unawaited (controller._updateMarkers (
463
466
MarkerUpdates .from (_markers.values.toSet (), widget.markers)));
464
467
_markers = keyByMarkerId (widget.markers);
465
468
}
466
469
467
- Future <void > _updateClusterManagers () async {
468
- final GoogleMapController controller = await _controller.future;
469
- if (! mounted) {
470
- return ;
471
- }
470
+ void _updateClusterManagers (GoogleMapController controller) {
472
471
unawaited (controller._updateClusterManagers (ClusterManagerUpdates .from (
473
472
_clusterManagers.values.toSet (), widget.clusterManagers)));
474
473
_clusterManagers = keyByClusterManagerId (widget.clusterManagers);
475
474
}
476
475
477
- Future <void > _updateGroundOverlays () async {
478
- final GoogleMapController controller = await _controller.future;
479
- if (! mounted) {
480
- return ;
481
- }
476
+ void _updateGroundOverlays (GoogleMapController controller) {
482
477
unawaited (controller._updateGroundOverlays (GroundOverlayUpdates .from (
483
478
_groundOverlays.values.toSet (), widget.groundOverlays)));
484
479
_groundOverlays = keyByGroundOverlayId (widget.groundOverlays);
485
480
}
486
481
487
- Future <void > _updatePolygons () async {
488
- final GoogleMapController controller = await _controller.future;
489
- if (! mounted) {
490
- return ;
491
- }
482
+ void _updatePolygons (GoogleMapController controller) {
492
483
unawaited (controller._updatePolygons (
493
484
PolygonUpdates .from (_polygons.values.toSet (), widget.polygons)));
494
485
_polygons = keyByPolygonId (widget.polygons);
495
486
}
496
487
497
- Future <void > _updatePolylines () async {
498
- final GoogleMapController controller = await _controller.future;
499
- if (! mounted) {
500
- return ;
501
- }
488
+ void _updatePolylines (GoogleMapController controller) {
502
489
unawaited (controller._updatePolylines (
503
490
PolylineUpdates .from (_polylines.values.toSet (), widget.polylines)));
504
491
_polylines = keyByPolylineId (widget.polylines);
505
492
}
506
493
507
- Future <void > _updateCircles () async {
508
- final GoogleMapController controller = await _controller.future;
509
- if (! mounted) {
510
- return ;
511
- }
494
+ void _updateCircles (GoogleMapController controller) {
512
495
unawaited (controller._updateCircles (
513
496
CircleUpdates .from (_circles.values.toSet (), widget.circles)));
514
497
_circles = keyByCircleId (widget.circles);
515
498
}
516
499
517
- Future <void > _updateHeatmaps () async {
518
- final GoogleMapController controller = await _controller.future;
519
- if (! mounted) {
520
- return ;
521
- }
500
+ void _updateHeatmaps (GoogleMapController controller) {
522
501
unawaited (
523
502
controller._updateHeatmaps (
524
503
HeatmapUpdates .from (_heatmaps.values.toSet (), widget.heatmaps),
@@ -527,11 +506,7 @@ class _GoogleMapState extends State<GoogleMap> {
527
506
_heatmaps = keyByHeatmapId (widget.heatmaps);
528
507
}
529
508
530
- Future <void > _updateTileOverlays () async {
531
- final GoogleMapController controller = await _controller.future;
532
- if (! mounted) {
533
- return ;
534
- }
509
+ void _updateTileOverlays (GoogleMapController controller) {
535
510
unawaited (controller._updateTileOverlays (widget.tileOverlays));
536
511
}
537
512
@@ -542,7 +517,7 @@ class _GoogleMapState extends State<GoogleMap> {
542
517
this ,
543
518
);
544
519
_controller.complete (controller);
545
- unawaited ( _updateTileOverlays () );
520
+ _updateTileOverlays (controller );
546
521
final MapCreatedCallback ? onMapCreated = widget.onMapCreated;
547
522
if (onMapCreated != null ) {
548
523
onMapCreated (controller);
0 commit comments