Skip to content

Commit ed9c0e0

Browse files
juaoosefreekvandeven
authored andcommitted
fix: follow theme brightness instead of platform
1 parent 62430d2 commit ed9c0e0

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/src/apple_map.dart

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class _AppleMapState extends State<AppleMap> {
192192
Widget build(BuildContext context) {
193193
final Map<String, dynamic> creationParams = <String, dynamic>{
194194
'initialCameraPosition': widget.initialCameraPosition._toMap(),
195-
'options': _appleMapOptions.toMap(),
195+
'options': _appleMapOptions.toMap(context: context),
196196
'annotationsToAdd': _serializeAnnotationSet(widget.annotations),
197197
'polylinesToAdd': _serializePolylineSet(widget.polylines),
198198
'polygonsToAdd': _serializePolygonSet(widget.polygons),
@@ -396,7 +396,7 @@ class _AppleMapOptions {
396396

397397
final bool? insetsLayoutMarginsFromSafeArea;
398398

399-
Map<String, dynamic> toMap() {
399+
Map<String, dynamic> toMap({BuildContext? context}) {
400400
final Map<String, dynamic> optionsMap = <String, dynamic>{};
401401

402402
void addIfNonNull(String fieldName, dynamic value) {
@@ -405,10 +405,22 @@ class _AppleMapOptions {
405405
}
406406
}
407407

408+
if (context != null) {
409+
final systemScheme = Theme.of(context).brightness == Brightness.dark
410+
? MapColorScheme.dark
411+
: MapColorScheme.light;
412+
addIfNonNull(
413+
'colorScheme',
414+
colorScheme == MapColorScheme.system
415+
? systemScheme.index
416+
: colorScheme?.index);
417+
} else {
418+
addIfNonNull('colorScheme', colorScheme?.index);
419+
}
420+
408421
addIfNonNull('compassEnabled', compassEnabled);
409422
addIfNonNull('trafficEnabled', trafficEnabled);
410423
addIfNonNull('mapType', mapType?.index);
411-
addIfNonNull('colorScheme', colorScheme?.index);
412424
addIfNonNull('minMaxZoomPreference', minMaxZoomPreference?._toJson());
413425
addIfNonNull('rotateGesturesEnabled', rotateGesturesEnabled);
414426
addIfNonNull('scrollGesturesEnabled', scrollGesturesEnabled);

0 commit comments

Comments
 (0)