@@ -192,7 +192,7 @@ class _AppleMapState extends State<AppleMap> {
192
192
Widget build (BuildContext context) {
193
193
final Map <String , dynamic > creationParams = < String , dynamic > {
194
194
'initialCameraPosition' : widget.initialCameraPosition._toMap (),
195
- 'options' : _appleMapOptions.toMap (),
195
+ 'options' : _appleMapOptions.toMap (context : context ),
196
196
'annotationsToAdd' : _serializeAnnotationSet (widget.annotations),
197
197
'polylinesToAdd' : _serializePolylineSet (widget.polylines),
198
198
'polygonsToAdd' : _serializePolygonSet (widget.polygons),
@@ -396,7 +396,7 @@ class _AppleMapOptions {
396
396
397
397
final bool ? insetsLayoutMarginsFromSafeArea;
398
398
399
- Map <String , dynamic > toMap () {
399
+ Map <String , dynamic > toMap ({ BuildContext ? context} ) {
400
400
final Map <String , dynamic > optionsMap = < String , dynamic > {};
401
401
402
402
void addIfNonNull (String fieldName, dynamic value) {
@@ -405,10 +405,22 @@ class _AppleMapOptions {
405
405
}
406
406
}
407
407
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
+
408
421
addIfNonNull ('compassEnabled' , compassEnabled);
409
422
addIfNonNull ('trafficEnabled' , trafficEnabled);
410
423
addIfNonNull ('mapType' , mapType? .index);
411
- addIfNonNull ('colorScheme' , colorScheme? .index);
412
424
addIfNonNull ('minMaxZoomPreference' , minMaxZoomPreference? ._toJson ());
413
425
addIfNonNull ('rotateGesturesEnabled' , rotateGesturesEnabled);
414
426
addIfNonNull ('scrollGesturesEnabled' , scrollGesturesEnabled);
0 commit comments