Skip to content

Commit 853ce32

Browse files
committed
Fixed BitmapDescriptor typing.
1 parent 9ce250b commit 853ce32

File tree

4 files changed

+79
-18
lines changed

4 files changed

+79
-18
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,5 @@ build/
7171
!**/ios/**/default.pbxuser
7272
!**/ios/**/default.perspectivev3
7373
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
74+
example/.flutter-plugins-dependencies
75+
example/ios/Flutter/Flutter.podspec

example/pubspec.lock

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,27 @@ packages:
88
url: "https://pub.dartlang.org"
99
source: hosted
1010
version: "0.0.6"
11+
archive:
12+
dependency: transitive
13+
description:
14+
name: archive
15+
url: "https://pub.dartlang.org"
16+
source: hosted
17+
version: "2.0.11"
18+
args:
19+
dependency: transitive
20+
description:
21+
name: args
22+
url: "https://pub.dartlang.org"
23+
source: hosted
24+
version: "1.5.2"
1125
async:
1226
dependency: transitive
1327
description:
1428
name: async
1529
url: "https://pub.dartlang.org"
1630
source: hosted
17-
version: "2.3.0"
31+
version: "2.4.0"
1832
boolean_selector:
1933
dependency: transitive
2034
description:
@@ -36,6 +50,20 @@ packages:
3650
url: "https://pub.dartlang.org"
3751
source: hosted
3852
version: "1.14.11"
53+
convert:
54+
dependency: transitive
55+
description:
56+
name: convert
57+
url: "https://pub.dartlang.org"
58+
source: hosted
59+
version: "2.1.1"
60+
crypto:
61+
dependency: transitive
62+
description:
63+
name: crypto
64+
url: "https://pub.dartlang.org"
65+
source: hosted
66+
version: "2.1.3"
3967
cupertino_icons:
4068
dependency: "direct main"
4169
description:
@@ -60,20 +88,27 @@ packages:
6088
url: "https://pub.dartlang.org"
6189
source: hosted
6290
version: "0.5.21+7"
91+
image:
92+
dependency: transitive
93+
description:
94+
name: image
95+
url: "https://pub.dartlang.org"
96+
source: hosted
97+
version: "2.1.4"
6398
matcher:
6499
dependency: transitive
65100
description:
66101
name: matcher
67102
url: "https://pub.dartlang.org"
68103
source: hosted
69-
version: "0.12.5"
104+
version: "0.12.6"
70105
meta:
71106
dependency: transitive
72107
description:
73108
name: meta
74109
url: "https://pub.dartlang.org"
75110
source: hosted
76-
version: "1.1.7"
111+
version: "1.1.8"
77112
path:
78113
dependency: transitive
79114
description:
@@ -88,6 +123,13 @@ packages:
88123
url: "https://pub.dartlang.org"
89124
source: hosted
90125
version: "1.8.0+1"
126+
petitparser:
127+
dependency: transitive
128+
description:
129+
name: petitparser
130+
url: "https://pub.dartlang.org"
131+
source: hosted
132+
version: "2.4.0"
91133
platform_maps_flutter:
92134
dependency: "direct main"
93135
description:
@@ -148,7 +190,7 @@ packages:
148190
name: test_api
149191
url: "https://pub.dartlang.org"
150192
source: hosted
151-
version: "0.2.5"
193+
version: "0.2.11"
152194
typed_data:
153195
dependency: transitive
154196
description:
@@ -163,6 +205,13 @@ packages:
163205
url: "https://pub.dartlang.org"
164206
source: hosted
165207
version: "2.0.8"
208+
xml:
209+
dependency: transitive
210+
description:
211+
name: xml
212+
url: "https://pub.dartlang.org"
213+
source: hosted
214+
version: "3.5.0"
166215
sdks:
167-
dart: ">=2.2.2 <3.0.0"
216+
dart: ">=2.4.0 <3.0.0"
168217
flutter: ">=1.5.0 <2.0.0"

lib/src/bitmap.dart

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,42 @@ part of flutter_platform_maps;
55
/// image to place on the surface of the earth.
66
77
class BitmapDescriptor {
8+
final dynamic bitmapDescriptor;
9+
10+
BitmapDescriptor._(this.bitmapDescriptor);
11+
812
/// Creates a BitmapDescriptor that refers to the default marker image.
9-
static dynamic get defaultMarker {
13+
static BitmapDescriptor get defaultMarker {
1014
if (Platform.isIOS) {
11-
return appleMaps.BitmapDescriptor.defaultAnnotation;
15+
return BitmapDescriptor._(appleMaps.BitmapDescriptor.defaultAnnotation);
1216
} else if (Platform.isAndroid) {
13-
return googleMaps.BitmapDescriptor.defaultMarker;
17+
return BitmapDescriptor._(googleMaps.BitmapDescriptor.defaultMarker);
1418
}
1519
return null;
1620
}
1721

18-
static dynamic fromAssetImage(
22+
static Future<BitmapDescriptor> fromAssetImage(
1923
ImageConfiguration configuration,
2024
String assetName, {
2125
AssetBundle bundle,
2226
String package,
23-
}) {
27+
}) async {
28+
dynamic bitmap;
2429
if (Platform.isIOS) {
25-
return appleMaps.BitmapDescriptor.fromAssetImage(
30+
bitmap = await appleMaps.BitmapDescriptor.fromAssetImage(
2631
configuration,
2732
assetName,
2833
bundle: bundle,
2934
package: package,
3035
);
3136
} else if (Platform.isAndroid) {
32-
return googleMaps.BitmapDescriptor.fromAssetImage(
37+
bitmap = googleMaps.BitmapDescriptor.fromAssetImage(
3338
configuration,
3439
assetName,
3540
bundle: bundle,
3641
package: package,
3742
);
3843
}
44+
return BitmapDescriptor._(bitmap);
3945
}
4046
}

lib/src/marker.dart

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class Marker {
122122
final bool draggable;
123123

124124
/// A description of the bitmap used to draw the marker icon.
125-
final dynamic icon;
125+
final BitmapDescriptor icon;
126126

127127
/// A Google Maps InfoWindow.
128128
///
@@ -146,7 +146,8 @@ class Marker {
146146
draggable: this.draggable,
147147
infoWindow: this.infoWindow.appleMapsInfoWindow,
148148
onTap: this.onTap,
149-
icon: this.icon ?? BitmapDescriptor.defaultMarker,
149+
icon: this.icon.bitmapDescriptor ??
150+
BitmapDescriptor.defaultMarker.bitmapDescriptor,
150151
visible: this.visible,
151152
onDragEnd: this.onDragEnd != null
152153
? (appleMaps.LatLng latLng) =>
@@ -161,7 +162,8 @@ class Marker {
161162
draggable: this.draggable,
162163
infoWindow: this.infoWindow.googleMapsInfoWindow,
163164
onTap: this.onTap,
164-
icon: this.icon ?? BitmapDescriptor.defaultMarker,
165+
icon: this.icon.bitmapDescriptor ??
166+
BitmapDescriptor.defaultMarker.bitmapDescriptor,
165167
visible: this.visible,
166168
onDragEnd: this.onDragEnd != null
167169
? (googleMaps.LatLng latLng) =>
@@ -177,7 +179,8 @@ class Marker {
177179
draggable: marker.draggable,
178180
infoWindow: marker.infoWindow.appleMapsInfoWindow,
179181
onTap: marker.onTap,
180-
icon: marker.icon ?? BitmapDescriptor.defaultMarker,
182+
icon: marker.icon?.bitmapDescriptor ??
183+
BitmapDescriptor.defaultMarker.bitmapDescriptor,
181184
visible: marker.visible,
182185
onDragEnd: marker.onDragEnd != null
183186
? (appleMaps.LatLng latLng) =>
@@ -193,7 +196,8 @@ class Marker {
193196
draggable: marker.draggable,
194197
infoWindow: marker.infoWindow.googleMapsInfoWindow,
195198
onTap: marker.onTap,
196-
icon: marker.icon ?? BitmapDescriptor.defaultMarker,
199+
icon: marker.icon?.bitmapDescriptor ??
200+
BitmapDescriptor.defaultMarker.bitmapDescriptor,
197201
visible: marker.visible,
198202
onDragEnd: marker.onDragEnd != null
199203
? (googleMaps.LatLng latLng) =>
@@ -223,7 +227,7 @@ class Marker {
223227
double alphaParam,
224228
bool consumeTapEventsParam,
225229
bool draggableParam,
226-
dynamic iconParam,
230+
BitmapDescriptor iconParam,
227231
InfoWindow infoWindowParam,
228232
LatLng positionParam,
229233
bool visibleParam,

0 commit comments

Comments
 (0)