Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 9f8fc64

Browse files
committed
[google_maps_flutter_web] Use size from BitmapDescriptor.fromBytes.
1 parent 720b762 commit 9f8fc64

File tree

7 files changed

+187
-78
lines changed

7 files changed

+187
-78
lines changed

packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.4.0+2
2+
3+
* Updates conversion of `BitmapDescriptor.fromBytes` marker icons to support the
4+
new `size` parameter. Issue [#73789](https://github.com/flutter/flutter/issues/73789).
5+
16
## 0.4.0+1
27

38
* Updates `README.md` to describe a hit-testing issue when Flutter widgets are overlaid on top of the Map widget.

packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.mocks.dart

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
// Mocks generated by Mockito 5.2.0 from annotations
1+
// Mocks generated by Mockito 5.3.0 from annotations
22
// in google_maps_flutter_web_integration_tests/integration_test/google_maps_controller_test.dart.
33
// Do not manually edit this file.
44

5+
// ignore_for_file: no_leading_underscores_for_library_prefixes
56
import 'package:google_maps/google_maps.dart' as _i2;
67
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'
78
as _i4;
@@ -17,8 +18,12 @@ import 'package:mockito/mockito.dart' as _i1;
1718
// ignore_for_file: prefer_const_constructors
1819
// ignore_for_file: unnecessary_parenthesis
1920
// ignore_for_file: camel_case_types
21+
// ignore_for_file: subtype_of_sealed_class
2022

21-
class _FakeGMap_0 extends _i1.Fake implements _i2.GMap {}
23+
class _FakeGMap_0 extends _i1.SmartFake implements _i2.GMap {
24+
_FakeGMap_0(Object parent, Invocation parentInvocation)
25+
: super(parent, parentInvocation);
26+
}
2227

2328
/// A class which mocks [CirclesController].
2429
///
@@ -27,18 +32,21 @@ class MockCirclesController extends _i1.Mock implements _i3.CirclesController {
2732
@override
2833
Map<_i4.CircleId, _i3.CircleController> get circles =>
2934
(super.noSuchMethod(Invocation.getter(#circles),
30-
returnValue: <_i4.CircleId, _i3.CircleController>{})
35+
returnValue: <_i4.CircleId, _i3.CircleController>{},
36+
returnValueForMissingStub: <_i4.CircleId, _i3.CircleController>{})
3137
as Map<_i4.CircleId, _i3.CircleController>);
3238
@override
3339
_i2.GMap get googleMap => (super.noSuchMethod(Invocation.getter(#googleMap),
34-
returnValue: _FakeGMap_0()) as _i2.GMap);
40+
returnValue: _FakeGMap_0(this, Invocation.getter(#googleMap)),
41+
returnValueForMissingStub:
42+
_FakeGMap_0(this, Invocation.getter(#googleMap))) as _i2.GMap);
3543
@override
3644
set googleMap(_i2.GMap? _googleMap) =>
3745
super.noSuchMethod(Invocation.setter(#googleMap, _googleMap),
3846
returnValueForMissingStub: null);
3947
@override
40-
int get mapId =>
41-
(super.noSuchMethod(Invocation.getter(#mapId), returnValue: 0) as int);
48+
int get mapId => (super.noSuchMethod(Invocation.getter(#mapId),
49+
returnValue: 0, returnValueForMissingStub: 0) as int);
4250
@override
4351
set mapId(int? _mapId) =>
4452
super.noSuchMethod(Invocation.setter(#mapId, _mapId),
@@ -67,20 +75,23 @@ class MockCirclesController extends _i1.Mock implements _i3.CirclesController {
6775
class MockPolygonsController extends _i1.Mock
6876
implements _i3.PolygonsController {
6977
@override
70-
Map<_i4.PolygonId, _i3.PolygonController> get polygons =>
71-
(super.noSuchMethod(Invocation.getter(#polygons),
72-
returnValue: <_i4.PolygonId, _i3.PolygonController>{})
73-
as Map<_i4.PolygonId, _i3.PolygonController>);
78+
Map<_i4.PolygonId, _i3.PolygonController> get polygons => (super.noSuchMethod(
79+
Invocation.getter(#polygons),
80+
returnValue: <_i4.PolygonId, _i3.PolygonController>{},
81+
returnValueForMissingStub: <_i4.PolygonId, _i3.PolygonController>{})
82+
as Map<_i4.PolygonId, _i3.PolygonController>);
7483
@override
7584
_i2.GMap get googleMap => (super.noSuchMethod(Invocation.getter(#googleMap),
76-
returnValue: _FakeGMap_0()) as _i2.GMap);
85+
returnValue: _FakeGMap_0(this, Invocation.getter(#googleMap)),
86+
returnValueForMissingStub:
87+
_FakeGMap_0(this, Invocation.getter(#googleMap))) as _i2.GMap);
7788
@override
7889
set googleMap(_i2.GMap? _googleMap) =>
7990
super.noSuchMethod(Invocation.setter(#googleMap, _googleMap),
8091
returnValueForMissingStub: null);
8192
@override
82-
int get mapId =>
83-
(super.noSuchMethod(Invocation.getter(#mapId), returnValue: 0) as int);
93+
int get mapId => (super.noSuchMethod(Invocation.getter(#mapId),
94+
returnValue: 0, returnValueForMissingStub: 0) as int);
8495
@override
8596
set mapId(int? _mapId) =>
8697
super.noSuchMethod(Invocation.setter(#mapId, _mapId),
@@ -109,20 +120,23 @@ class MockPolygonsController extends _i1.Mock
109120
class MockPolylinesController extends _i1.Mock
110121
implements _i3.PolylinesController {
111122
@override
112-
Map<_i4.PolylineId, _i3.PolylineController> get lines =>
113-
(super.noSuchMethod(Invocation.getter(#lines),
114-
returnValue: <_i4.PolylineId, _i3.PolylineController>{})
115-
as Map<_i4.PolylineId, _i3.PolylineController>);
123+
Map<_i4.PolylineId, _i3.PolylineController> get lines => (super.noSuchMethod(
124+
Invocation.getter(#lines),
125+
returnValue: <_i4.PolylineId, _i3.PolylineController>{},
126+
returnValueForMissingStub: <_i4.PolylineId, _i3.PolylineController>{})
127+
as Map<_i4.PolylineId, _i3.PolylineController>);
116128
@override
117129
_i2.GMap get googleMap => (super.noSuchMethod(Invocation.getter(#googleMap),
118-
returnValue: _FakeGMap_0()) as _i2.GMap);
130+
returnValue: _FakeGMap_0(this, Invocation.getter(#googleMap)),
131+
returnValueForMissingStub:
132+
_FakeGMap_0(this, Invocation.getter(#googleMap))) as _i2.GMap);
119133
@override
120134
set googleMap(_i2.GMap? _googleMap) =>
121135
super.noSuchMethod(Invocation.setter(#googleMap, _googleMap),
122136
returnValueForMissingStub: null);
123137
@override
124-
int get mapId =>
125-
(super.noSuchMethod(Invocation.getter(#mapId), returnValue: 0) as int);
138+
int get mapId => (super.noSuchMethod(Invocation.getter(#mapId),
139+
returnValue: 0, returnValueForMissingStub: 0) as int);
126140
@override
127141
set mapId(int? _mapId) =>
128142
super.noSuchMethod(Invocation.setter(#mapId, _mapId),
@@ -152,18 +166,21 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
152166
@override
153167
Map<_i4.MarkerId, _i3.MarkerController> get markers =>
154168
(super.noSuchMethod(Invocation.getter(#markers),
155-
returnValue: <_i4.MarkerId, _i3.MarkerController>{})
169+
returnValue: <_i4.MarkerId, _i3.MarkerController>{},
170+
returnValueForMissingStub: <_i4.MarkerId, _i3.MarkerController>{})
156171
as Map<_i4.MarkerId, _i3.MarkerController>);
157172
@override
158173
_i2.GMap get googleMap => (super.noSuchMethod(Invocation.getter(#googleMap),
159-
returnValue: _FakeGMap_0()) as _i2.GMap);
174+
returnValue: _FakeGMap_0(this, Invocation.getter(#googleMap)),
175+
returnValueForMissingStub:
176+
_FakeGMap_0(this, Invocation.getter(#googleMap))) as _i2.GMap);
160177
@override
161178
set googleMap(_i2.GMap? _googleMap) =>
162179
super.noSuchMethod(Invocation.setter(#googleMap, _googleMap),
163180
returnValueForMissingStub: null);
164181
@override
165-
int get mapId =>
166-
(super.noSuchMethod(Invocation.getter(#mapId), returnValue: 0) as int);
182+
int get mapId => (super.noSuchMethod(Invocation.getter(#mapId),
183+
returnValue: 0, returnValueForMissingStub: 0) as int);
167184
@override
168185
set mapId(int? _mapId) =>
169186
super.noSuchMethod(Invocation.setter(#mapId, _mapId),
@@ -191,7 +208,7 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
191208
@override
192209
bool isInfoWindowShown(_i4.MarkerId? markerId) =>
193210
(super.noSuchMethod(Invocation.method(#isInfoWindowShown, [markerId]),
194-
returnValue: false) as bool);
211+
returnValue: false, returnValueForMissingStub: false) as bool);
195212
@override
196213
void bindToMap(int? mapId, _i2.GMap? googleMap) =>
197214
super.noSuchMethod(Invocation.method(#bindToMap, [mapId, googleMap]),

packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.mocks.dart

Lines changed: 59 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
// Mocks generated by Mockito 5.2.0 from annotations
1+
// Mocks generated by Mockito 5.3.0 from annotations
22
// in google_maps_flutter_web_integration_tests/integration_test/google_maps_plugin_test.dart.
33
// Do not manually edit this file.
44

5+
// ignore_for_file: no_leading_underscores_for_library_prefixes
56
import 'dart:async' as _i2;
67

78
import 'package:google_maps/google_maps.dart' as _i5;
@@ -19,36 +20,53 @@ import 'package:mockito/mockito.dart' as _i1;
1920
// ignore_for_file: prefer_const_constructors
2021
// ignore_for_file: unnecessary_parenthesis
2122
// ignore_for_file: camel_case_types
23+
// ignore_for_file: subtype_of_sealed_class
2224

23-
class _FakeStreamController_0<T> extends _i1.Fake
24-
implements _i2.StreamController<T> {}
25+
class _FakeStreamController_0<T> extends _i1.SmartFake
26+
implements _i2.StreamController<T> {
27+
_FakeStreamController_0(Object parent, Invocation parentInvocation)
28+
: super(parent, parentInvocation);
29+
}
2530

26-
class _FakeLatLngBounds_1 extends _i1.Fake implements _i3.LatLngBounds {}
31+
class _FakeLatLngBounds_1 extends _i1.SmartFake implements _i3.LatLngBounds {
32+
_FakeLatLngBounds_1(Object parent, Invocation parentInvocation)
33+
: super(parent, parentInvocation);
34+
}
2735

28-
class _FakeScreenCoordinate_2 extends _i1.Fake implements _i3.ScreenCoordinate {
36+
class _FakeScreenCoordinate_2 extends _i1.SmartFake
37+
implements _i3.ScreenCoordinate {
38+
_FakeScreenCoordinate_2(Object parent, Invocation parentInvocation)
39+
: super(parent, parentInvocation);
2940
}
3041

31-
class _FakeLatLng_3 extends _i1.Fake implements _i3.LatLng {}
42+
class _FakeLatLng_3 extends _i1.SmartFake implements _i3.LatLng {
43+
_FakeLatLng_3(Object parent, Invocation parentInvocation)
44+
: super(parent, parentInvocation);
45+
}
3246

3347
/// A class which mocks [GoogleMapController].
3448
///
3549
/// See the documentation for Mockito's code generation for more information.
3650
class MockGoogleMapController extends _i1.Mock
3751
implements _i4.GoogleMapController {
3852
@override
39-
_i2.StreamController<_i3.MapEvent<Object?>> get stream =>
40-
(super.noSuchMethod(Invocation.getter(#stream),
41-
returnValue: _FakeStreamController_0<_i3.MapEvent<Object?>>())
42-
as _i2.StreamController<_i3.MapEvent<Object?>>);
53+
_i2.StreamController<_i3.MapEvent<Object?>> get stream => (super.noSuchMethod(
54+
Invocation.getter(#stream),
55+
returnValue: _FakeStreamController_0<_i3.MapEvent<Object?>>(
56+
this, Invocation.getter(#stream)),
57+
returnValueForMissingStub: _FakeStreamController_0<_i3.MapEvent<Object?>>(
58+
this, Invocation.getter(#stream))) as _i2
59+
.StreamController<_i3.MapEvent<Object?>>);
4360
@override
44-
_i2.Stream<_i3.MapEvent<Object?>> get events =>
45-
(super.noSuchMethod(Invocation.getter(#events),
46-
returnValue: Stream<_i3.MapEvent<Object?>>.empty())
47-
as _i2.Stream<_i3.MapEvent<Object?>>);
61+
_i2.Stream<_i3.MapEvent<Object?>> get events => (super.noSuchMethod(
62+
Invocation.getter(#events),
63+
returnValue: _i2.Stream<_i3.MapEvent<Object?>>.empty(),
64+
returnValueForMissingStub: _i2.Stream<_i3.MapEvent<Object?>>.empty())
65+
as _i2.Stream<_i3.MapEvent<Object?>>);
4866
@override
4967
bool get isInitialized =>
50-
(super.noSuchMethod(Invocation.getter(#isInitialized), returnValue: false)
51-
as bool);
68+
(super.noSuchMethod(Invocation.getter(#isInitialized),
69+
returnValue: false, returnValueForMissingStub: false) as bool);
5270
@override
5371
void debugSetOverrides(
5472
{_i4.DebugCreateMapFunction? createMap,
@@ -78,29 +96,43 @@ class MockGoogleMapController extends _i1.Mock
7896
returnValueForMissingStub: null);
7997
@override
8098
_i2.Future<_i3.LatLngBounds> getVisibleRegion() => (super.noSuchMethod(
81-
Invocation.method(#getVisibleRegion, []),
82-
returnValue: Future<_i3.LatLngBounds>.value(_FakeLatLngBounds_1()))
83-
as _i2.Future<_i3.LatLngBounds>);
99+
Invocation.method(#getVisibleRegion, []),
100+
returnValue: _i2.Future<_i3.LatLngBounds>.value(
101+
_FakeLatLngBounds_1(this, Invocation.method(#getVisibleRegion, []))),
102+
returnValueForMissingStub: _i2.Future<_i3.LatLngBounds>.value(
103+
_FakeLatLngBounds_1(
104+
this, Invocation.method(#getVisibleRegion, [])))) as _i2
105+
.Future<_i3.LatLngBounds>);
84106
@override
85107
_i2.Future<_i3.ScreenCoordinate> getScreenCoordinate(_i3.LatLng? latLng) =>
86108
(super.noSuchMethod(Invocation.method(#getScreenCoordinate, [latLng]),
87-
returnValue:
88-
Future<_i3.ScreenCoordinate>.value(_FakeScreenCoordinate_2()))
109+
returnValue: _i2.Future<_i3.ScreenCoordinate>.value(
110+
_FakeScreenCoordinate_2(
111+
this, Invocation.method(#getScreenCoordinate, [latLng]))),
112+
returnValueForMissingStub: _i2.Future<_i3.ScreenCoordinate>.value(
113+
_FakeScreenCoordinate_2(
114+
this, Invocation.method(#getScreenCoordinate, [latLng]))))
89115
as _i2.Future<_i3.ScreenCoordinate>);
90116
@override
91117
_i2.Future<_i3.LatLng> getLatLng(_i3.ScreenCoordinate? screenCoordinate) =>
92118
(super.noSuchMethod(Invocation.method(#getLatLng, [screenCoordinate]),
93-
returnValue: Future<_i3.LatLng>.value(_FakeLatLng_3()))
94-
as _i2.Future<_i3.LatLng>);
119+
returnValue: _i2.Future<_i3.LatLng>.value(_FakeLatLng_3(
120+
this, Invocation.method(#getLatLng, [screenCoordinate]))),
121+
returnValueForMissingStub: _i2.Future<_i3.LatLng>.value(_FakeLatLng_3(
122+
this, Invocation.method(#getLatLng, [screenCoordinate])))) as _i2
123+
.Future<_i3.LatLng>);
95124
@override
96125
_i2.Future<void> moveCamera(_i3.CameraUpdate? cameraUpdate) =>
97126
(super.noSuchMethod(Invocation.method(#moveCamera, [cameraUpdate]),
98-
returnValue: Future<void>.value(),
99-
returnValueForMissingStub: Future<void>.value()) as _i2.Future<void>);
127+
returnValue: _i2.Future<void>.value(),
128+
returnValueForMissingStub: _i2.Future<void>.value())
129+
as _i2.Future<void>);
100130
@override
101131
_i2.Future<double> getZoomLevel() =>
102132
(super.noSuchMethod(Invocation.method(#getZoomLevel, []),
103-
returnValue: Future<double>.value(0.0)) as _i2.Future<double>);
133+
returnValue: _i2.Future<double>.value(0.0),
134+
returnValueForMissingStub: _i2.Future<double>.value(0.0))
135+
as _i2.Future<double>);
104136
@override
105137
void updateCircles(_i3.CircleUpdates? updates) =>
106138
super.noSuchMethod(Invocation.method(#updateCircles, [updates]),
@@ -128,7 +160,7 @@ class MockGoogleMapController extends _i1.Mock
128160
@override
129161
bool isInfoWindowShown(_i3.MarkerId? markerId) =>
130162
(super.noSuchMethod(Invocation.method(#isInfoWindowShown, [markerId]),
131-
returnValue: false) as bool);
163+
returnValue: false, returnValueForMissingStub: false) as bool);
132164
@override
133165
void dispose() => super.noSuchMethod(Invocation.method(#dispose, []),
134166
returnValueForMissingStub: null);

packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/markers_test.dart

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import 'dart:async';
66
import 'dart:convert';
77
import 'dart:html' as html;
8-
import 'dart:js_util' show getProperty;
98
import 'dart:typed_data';
9+
import 'dart:ui';
1010

1111
import 'package:flutter_test/flutter_test.dart';
1212
import 'package:google_maps/google_maps.dart' as gmaps;
@@ -155,22 +155,46 @@ void main() {
155155
controller.addMarkers(markers);
156156

157157
expect(controller.markers.length, 1);
158-
expect(controller.markers[const MarkerId('1')]?.marker?.icon, isNotNull);
159-
160-
final String blobUrl = getProperty<String>(
161-
controller.markers[const MarkerId('1')]!.marker!.icon!,
162-
'url',
163-
);
158+
final gmaps.Icon? icon =
159+
controller.markers[const MarkerId('1')]?.marker?.icon as gmaps.Icon?;
160+
expect(icon, isNotNull);
164161

162+
final String blobUrl = icon!.url!;
165163
expect(blobUrl, startsWith('blob:'));
166164

167165
final http.Response response = await http.get(Uri.parse(blobUrl));
168-
169166
expect(response.bodyBytes, bytes,
170167
reason:
171168
'Bytes from the Icon blob must match bytes used to create Marker');
172169
});
173170

171+
// https://github.com/flutter/flutter/issues/73789
172+
testWidgets('markers with custom bitmap icon pass size to sdk',
173+
(WidgetTester tester) async {
174+
final Uint8List bytes = const Base64Decoder().convert(iconImageBase64);
175+
final Set<Marker> markers = <Marker>{
176+
Marker(
177+
markerId: const MarkerId('1'),
178+
icon: BitmapDescriptor.fromBytes(bytes, size: const Size(20, 30)),
179+
),
180+
};
181+
182+
controller.addMarkers(markers);
183+
184+
expect(controller.markers.length, 1);
185+
final gmaps.Icon? icon =
186+
controller.markers[const MarkerId('1')]?.marker?.icon as gmaps.Icon?;
187+
expect(icon, isNotNull);
188+
189+
final gmaps.Size size = icon!.size!;
190+
final gmaps.Size scaledSize = icon.scaledSize!;
191+
192+
expect(size.width, 20);
193+
expect(size.height, 30);
194+
expect(scaledSize.width, 20);
195+
expect(scaledSize.height, 30);
196+
});
197+
174198
// https://github.com/flutter/flutter/issues/67854
175199
testWidgets('InfoWindow snippet can have links',
176200
(WidgetTester tester) async {

packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ dependencies:
1212
google_maps_flutter_web:
1313
path: ../
1414

15+
dependency_overrides:
16+
google_maps_flutter_platform_interface:
17+
path: ../../google_maps_flutter_platform_interface
18+
1519
dev_dependencies:
1620
build_runner: ^2.1.1
1721
flutter_driver:

0 commit comments

Comments
 (0)