Skip to content

Commit 1c2d939

Browse files
committed
Fix typecasting errors when decoding layer properties
1 parent 2e84334 commit 1c2d939

File tree

10 files changed

+65
-26
lines changed

10 files changed

+65
-26
lines changed

example/integration_test/location_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ void main() {
6565
expect(updatedSettings.puckBearingSource, settings.puckBearingSource);
6666
expect(updatedSettings.showAccuracyRing, settings.showAccuracyRing);
6767
// FIXME bitmaps are decoded incorrectly for some reason
68-
expect(updatedSettings.accuracyRingBorderColor, settings.accuracyRingBorderColor);
68+
expect(updatedSettings.accuracyRingBorderColor,
69+
settings.accuracyRingBorderColor);
6970
expect(updatedSettings.accuracyRingColor, settings.accuracyRingColor);
7071
// expect(updatedSettings.locationPuck?.locationPuck2D?.bearingImage,
7172
// settings.locationPuck?.locationPuck2D?.bearingImage);

example/ios/Podfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ PODS:
22
- Flutter (1.0.0)
33
- integration_test (0.0.1):
44
- Flutter
5-
- mapbox_maps_flutter (0.4.4):
5+
- mapbox_maps_flutter (0.4.5):
66
- Flutter
77
- MapboxMaps (~> 10.13.1)
88
- MapboxCommon (23.5.0)
@@ -45,7 +45,7 @@ EXTERNAL SOURCES:
4545
SPEC CHECKSUMS:
4646
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
4747
integration_test: 13825b8a9334a850581300559b8839134b124670
48-
mapbox_maps_flutter: b7750303639682268cc7f487bfc6f474a456acab
48+
mapbox_maps_flutter: d86eb8d532ae2f7e5d389fff3aa197b743d3c747
4949
MapboxCommon: fdf7fd31c90b7b607cd9c63e37797f023c01d860
5050
MapboxCoreMaps: 24270c7c6b8cb71819fc2f3c549db9620ee4d019
5151
MapboxMaps: cb76511b98d3b95c74b0771ed105bc69f30ace6b
@@ -55,4 +55,4 @@ SPEC CHECKSUMS:
5555

5656
PODFILE CHECKSUM: 04c8a50f0eb98e8e64bc4237a0712e89ba6c14b8
5757

58-
COCOAPODS: 1.12.1
58+
COCOAPODS: 1.13.0

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ packages:
144144
path: ".."
145145
relative: true
146146
source: path
147-
version: "0.4.4"
147+
version: "0.4.5"
148148
matcher:
149149
dependency: transitive
150150
description:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import 'package:integration_test/integration_test_driver.dart';
22

3-
Future<void> main() => integrationDriver();
3+
Future<void> main() => integrationDriver();

lib/src/style/layer/background_layer.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ class BackgroundLayer extends Layer {
8383
backgroundOpacity: map["paint"]["background-opacity"] is num?
8484
? (map["paint"]["background-opacity"] as num?)?.toDouble()
8585
: null,
86-
backgroundPattern: map["paint"]["background-pattern"],
86+
backgroundPattern: map["layout"]["background-pattern"] is String?
87+
? map["layout"]["background-pattern"] as String?
88+
: null,
8789
);
8890
}
8991
}

lib/src/style/layer/fill_extrusion_layer.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ class FillExtrusionLayer extends Layer {
143143
fillExtrusionOpacity: map["paint"]["fill-extrusion-opacity"] is num?
144144
? (map["paint"]["fill-extrusion-opacity"] as num?)?.toDouble()
145145
: null,
146-
fillExtrusionPattern: map["paint"]["fill-extrusion-pattern"],
146+
fillExtrusionPattern: map["layout"]["fill-extrusion-pattern"] is String?
147+
? map["layout"]["fill-extrusion-pattern"] as String?
148+
: null,
147149
fillExtrusionTranslate:
148150
(map["paint"]["fill-extrusion-translate"] as List?)
149151
?.map<double?>((e) => e.toDouble())
@@ -157,8 +159,10 @@ class FillExtrusionLayer extends Layer {
157159
.last
158160
.toLowerCase()
159161
.contains(map["paint"]["fill-extrusion-translate-anchor"])),
160-
fillExtrusionVerticalGradient: map["paint"]
161-
["fill-extrusion-vertical-gradient"],
162+
fillExtrusionVerticalGradient:
163+
map["layout"]["fill-extrusion-vertical-gradient"] is bool?
164+
? map["layout"]["fill-extrusion-vertical-gradient"] as bool?
165+
: null,
162166
);
163167
}
164168
}

lib/src/style/layer/fill_layer.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,18 @@ class FillLayer extends Layer {
132132
fillSortKey: map["layout"]["fill-sort-key"] is num?
133133
? (map["layout"]["fill-sort-key"] as num?)?.toDouble()
134134
: null,
135-
fillAntialias: map["paint"]["fill-antialias"],
135+
fillAntialias: map["layout"]["fill-antialias"] is bool?
136+
? map["layout"]["fill-antialias"] as bool?
137+
: null,
136138
fillColor: (map["paint"]["fill-color"] as List?)?.toRGBAInt(),
137139
fillOpacity: map["paint"]["fill-opacity"] is num?
138140
? (map["paint"]["fill-opacity"] as num?)?.toDouble()
139141
: null,
140142
fillOutlineColor:
141143
(map["paint"]["fill-outline-color"] as List?)?.toRGBAInt(),
142-
fillPattern: map["paint"]["fill-pattern"],
144+
fillPattern: map["layout"]["fill-pattern"] is String?
145+
? map["layout"]["fill-pattern"] as String?
146+
: null,
143147
fillTranslate: (map["paint"]["fill-translate"] as List?)
144148
?.map<double?>((e) => e.toDouble())
145149
.toList(),

lib/src/style/layer/line_layer.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ class LineLayer extends Layer {
234234
lineOpacity: map["paint"]["line-opacity"] is num?
235235
? (map["paint"]["line-opacity"] as num?)?.toDouble()
236236
: null,
237-
linePattern: map["paint"]["line-pattern"],
237+
linePattern: map["layout"]["line-pattern"] is String?
238+
? map["layout"]["line-pattern"] as String?
239+
: null,
238240
lineTranslate: (map["paint"]["line-translate"] as List?)
239241
?.map<double?>((e) => e.toDouble())
240242
.toList(),

lib/src/style/layer/location_indicator_layer.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,15 @@ class LocationIndicatorLayer extends Layer {
164164
.last
165165
.toLowerCase()
166166
.contains(map["layout"]["visibility"])),
167-
bearingImage: map["layout"]["bearing-image"],
168-
shadowImage: map["layout"]["shadow-image"],
169-
topImage: map["layout"]["top-image"],
167+
bearingImage: map["layout"]["bearing-image"] is String?
168+
? map["layout"]["bearing-image"] as String?
169+
: null,
170+
shadowImage: map["layout"]["shadow-image"] is String?
171+
? map["layout"]["shadow-image"] as String?
172+
: null,
173+
topImage: map["layout"]["top-image"] is String?
174+
? map["layout"]["top-image"] as String?
175+
: null,
170176
accuracyRadius: map["paint"]["accuracy-radius"] is num?
171177
? (map["paint"]["accuracy-radius"] as num?)?.toDouble()
172178
: null,

lib/src/style/layer/symbol_layer.dart

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,9 @@ class SymbolLayer extends Layer {
463463
.last
464464
.toLowerCase()
465465
.contains(map["layout"]["visibility"])),
466-
iconAllowOverlap: map["layout"]["icon-allow-overlap"],
466+
iconAllowOverlap: map["layout"]["icon-allow-overlap"] is bool?
467+
? map["layout"]["icon-allow-overlap"] as bool?
468+
: null,
467469
iconAnchor: map["layout"]["icon-anchor"] == null
468470
? null
469471
: IconAnchor.values.firstWhere((e) => e
@@ -472,13 +474,21 @@ class SymbolLayer extends Layer {
472474
.last
473475
.toLowerCase()
474476
.contains(map["layout"]["icon-anchor"])),
475-
iconIgnorePlacement: map["layout"]["icon-ignore-placement"],
476-
iconImage: map["layout"]["icon-image"],
477-
iconKeepUpright: map["layout"]["icon-keep-upright"],
477+
iconIgnorePlacement: map["layout"]["icon-ignore-placement"] is bool?
478+
? map["layout"]["icon-ignore-placement"] as bool?
479+
: null,
480+
iconImage: map["layout"]["icon-image"] is String?
481+
? map["layout"]["icon-image"] as String?
482+
: null,
483+
iconKeepUpright: map["layout"]["icon-keep-upright"] is bool?
484+
? map["layout"]["icon-keep-upright"] as bool?
485+
: null,
478486
iconOffset: (map["layout"]["icon-offset"] as List?)
479487
?.map<double?>((e) => e.toDouble())
480488
.toList(),
481-
iconOptional: map["layout"]["icon-optional"],
489+
iconOptional: map["layout"]["icon-optional"] is bool?
490+
? map["layout"]["icon-optional"] as bool?
491+
: null,
482492
iconPadding: map["layout"]["icon-padding"] is num?
483493
? (map["layout"]["icon-padding"] as num?)?.toDouble()
484494
: null,
@@ -515,7 +525,9 @@ class SymbolLayer extends Layer {
515525
iconTextFitPadding: (map["layout"]["icon-text-fit-padding"] as List?)
516526
?.map<double?>((e) => e.toDouble())
517527
.toList(),
518-
symbolAvoidEdges: map["layout"]["symbol-avoid-edges"],
528+
symbolAvoidEdges: map["layout"]["symbol-avoid-edges"] is bool?
529+
? map["layout"]["symbol-avoid-edges"] as bool?
530+
: null,
519531
symbolPlacement: map["layout"]["symbol-placement"] == null
520532
? null
521533
: SymbolPlacement.values.firstWhere((e) => e
@@ -538,7 +550,9 @@ class SymbolLayer extends Layer {
538550
.last
539551
.toLowerCase()
540552
.contains(map["layout"]["symbol-z-order"])),
541-
textAllowOverlap: map["layout"]["text-allow-overlap"],
553+
textAllowOverlap: map["layout"]["text-allow-overlap"] is bool?
554+
? map["layout"]["text-allow-overlap"] as bool?
555+
: null,
542556
textAnchor: map["layout"]["text-anchor"] == null
543557
? null
544558
: TextAnchor.values.firstWhere((e) => e
@@ -550,7 +564,9 @@ class SymbolLayer extends Layer {
550564
textFont: (map["layout"]["text-font"] as List?)
551565
?.map<String?>((e) => e.toString())
552566
.toList(),
553-
textIgnorePlacement: map["layout"]["text-ignore-placement"],
567+
textIgnorePlacement: map["layout"]["text-ignore-placement"] is bool?
568+
? map["layout"]["text-ignore-placement"] as bool?
569+
: null,
554570
textJustify: map["layout"]["text-justify"] == null
555571
? null
556572
: TextJustify.values.firstWhere((e) => e
@@ -559,7 +575,9 @@ class SymbolLayer extends Layer {
559575
.last
560576
.toLowerCase()
561577
.contains(map["layout"]["text-justify"])),
562-
textKeepUpright: map["layout"]["text-keep-upright"],
578+
textKeepUpright: map["layout"]["text-keep-upright"] is bool?
579+
? map["layout"]["text-keep-upright"] as bool?
580+
: null,
563581
textLetterSpacing: map["layout"]["text-letter-spacing"] is num?
564582
? (map["layout"]["text-letter-spacing"] as num?)?.toDouble()
565583
: null,
@@ -575,7 +593,9 @@ class SymbolLayer extends Layer {
575593
textOffset: (map["layout"]["text-offset"] as List?)
576594
?.map<double?>((e) => e.toDouble())
577595
.toList(),
578-
textOptional: map["layout"]["text-optional"],
596+
textOptional: map["layout"]["text-optional"] is bool?
597+
? map["layout"]["text-optional"] as bool?
598+
: null,
579599
textPadding: map["layout"]["text-padding"] is num?
580600
? (map["layout"]["text-padding"] as num?)?.toDouble()
581601
: null,

0 commit comments

Comments
 (0)