Skip to content

Commit

Permalink
[google_maps_flutter_web] Migrate to google_maps: 8.0.0 (#7077)
Browse files Browse the repository at this point in the history
Migrates `google_maps_flutter_web` to `google_maps: ^8.0.0`

Blocked on the following:
- a14n/dart-google-maps#132
- flutter/flutter#151426
- flutter/flutter#145149
- a14n/dart-google-maps#133
- flutter/flutter#151561

Fixes flutter/flutter#148624
  • Loading branch information
Rexios80 authored Jul 31, 2024
1 parent 5513396 commit b0b4469
Show file tree
Hide file tree
Showing 26 changed files with 389 additions and 308 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.5.9

* Updates `package:google_maps` dependency to latest (`^8.0.0`).
* Supports `web: ">=0.5.1 <2.0.0"`.
* Updates SDK version to Dart `^3.4.0`. Flutter `^3.22.0`.

## 0.5.8

* Adds support for BitmapDescriptor classes `AssetMapBitmap` and `BytesMapBitmap`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ If you need marker clustering support, modify the <head> tag to load the [js-mar

<!-- // Other stuff -->

<script src="https://unpkg.com/@googlemaps/[email protected]/dist/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@googlemaps/[email protected]/dist/index.umd.min.js"></script>
</head>
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,24 @@ import 'google_maps_controller_test.mocks.dart';
// LatLng values.
const String _kCloudMapId = '000000000000000'; // Dummy map ID.

gmaps.Map mapShim() => throw UnimplementedError();

@GenerateNiceMocks(<MockSpec<dynamic>>[
MockSpec<CirclesController>(),
MockSpec<PolygonsController>(),
MockSpec<PolylinesController>(),
MockSpec<MarkersController>(),
MockSpec<TileOverlaysController>(),
MockSpec<CirclesController>(
fallbackGenerators: <Symbol, Function>{#googleMap: mapShim},
),
MockSpec<PolygonsController>(
fallbackGenerators: <Symbol, Function>{#googleMap: mapShim},
),
MockSpec<PolylinesController>(
fallbackGenerators: <Symbol, Function>{#googleMap: mapShim},
),
MockSpec<MarkersController>(
fallbackGenerators: <Symbol, Function>{#googleMap: mapShim},
),
MockSpec<TileOverlaysController>(
fallbackGenerators: <Symbol, Function>{#googleMap: mapShim},
),
])

/// Test Google Map Controller
Expand Down Expand Up @@ -221,15 +233,15 @@ void main() {
late MockPolygonsController polygons;
late MockPolylinesController polylines;
late MockTileOverlaysController tileOverlays;
late gmaps.GMap map;
late gmaps.Map map;

setUp(() {
circles = MockCirclesController();
markers = MockMarkersController();
polygons = MockPolygonsController();
polylines = MockPolylinesController();
tileOverlays = MockTileOverlaysController();
map = gmaps.GMap(createDivElement());
map = gmaps.Map(createDivElement());
});

testWidgets('listens to map events', (WidgetTester tester) async {
Expand All @@ -246,19 +258,19 @@ void main() {
// Trigger events on the map, and verify they've been broadcast to the stream
final Stream<MapEvent<Object?>> capturedEvents = stream.stream.take(5);

gmaps.Event.trigger(
gmaps.event.trigger(
map,
'click',
<Object>[gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0)],
gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0),
);
gmaps.Event.trigger(
gmaps.event.trigger(
map,
'rightclick',
<Object>[gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0)],
gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0),
);
// The following line causes 2 events
gmaps.Event.trigger(map, 'bounds_changed', <Object>[]);
gmaps.Event.trigger(map, 'idle', <Object>[]);
gmaps.event.trigger(map, 'bounds_changed');
gmaps.event.trigger(map, 'idle');

final List<MapEvent<Object?>> events = await capturedEvents.toList();

Expand Down Expand Up @@ -539,12 +551,12 @@ void main() {
});
});

// These are the methods that are delegated to the gmaps.GMap object, that we can mock...
// These are the methods that are delegated to the gmaps.Map object, that we can mock...
group('Map control methods', () {
late gmaps.GMap map;
late gmaps.Map map;

setUp(() {
map = gmaps.GMap(
map = gmaps.Map(
createDivElement(),
gmaps.MapOptions()
..zoom = 10
Expand Down Expand Up @@ -604,7 +616,7 @@ void main() {

group('viewport getters', () {
testWidgets('getVisibleRegion', (WidgetTester tester) async {
final gmaps.LatLng gmCenter = map.center!;
final gmaps.LatLng gmCenter = map.center;
final LatLng center =
LatLng(gmCenter.lat.toDouble(), gmCenter.lng.toDouble());

Expand Down
Loading

0 comments on commit b0b4469

Please sign in to comment.