Skip to content

Commit 5bc0f0b

Browse files
committed
Adds insetsLayoutMarginsFromSafeArea param
1 parent 2414c34 commit 5bc0f0b

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

example/lib/scrolling_map.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class ScrollingMapBody extends StatelessWidget {
2929
@override
3030
Widget build(BuildContext context) {
3131
return SafeArea(
32+
bottom: false,
3233
child: ListView(
3334
children: <Widget>[
3435
Card(
@@ -99,6 +100,7 @@ class ScrollingMapBody extends StatelessWidget {
99100
() => ScaleGestureRecognizer(),
100101
),
101102
].toSet(),
103+
insetsLayoutMarginsFromSafeArea: false,
102104
),
103105
),
104106
),

ios/Classes/MapView/FlutterMapView.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ class FlutterMapView: MKMapView, UIGestureRecognizerDelegate {
194194
self.maxZoomLevel = _maxZoom
195195
}
196196
}
197+
198+
if let insetsSafeArea: Bool = options["insetsLayoutMarginsFromSafeArea"] as? Bool {
199+
if #available(iOS 11.0, *) {
200+
self.insetsLayoutMarginsFromSafeArea = insetsSafeArea
201+
}
202+
}
203+
197204
}
198205

199206
func setUserLocation() {

lib/src/apple_map.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class AppleMap extends StatefulWidget {
4242
this.onTap,
4343
this.onLongPress,
4444
this.snapshotOptions,
45+
this.insetsLayoutMarginsFromSafeArea = true,
4546
}) : super(key: key);
4647

4748
final MapCreatedCallback? onMapCreated;
@@ -165,6 +166,10 @@ class AppleMap extends StatefulWidget {
165166

166167
final SnapshotOptions? snapshotOptions;
167168

169+
/// A Boolean value indicating whether the view's layout margins are updated
170+
/// automatically to reflect the safe area.
171+
final bool insetsLayoutMarginsFromSafeArea;
172+
168173
@override
169174
State createState() => _AppleMapState();
170175
}
@@ -336,6 +341,7 @@ class _AppleMapOptions {
336341
this.myLocationEnabled,
337342
this.myLocationButtonEnabled,
338343
this.padding,
344+
this.insetsLayoutMarginsFromSafeArea,
339345
});
340346

341347
static _AppleMapOptions fromWidget(AppleMap map) {
@@ -352,6 +358,7 @@ class _AppleMapOptions {
352358
myLocationEnabled: map.myLocationEnabled,
353359
myLocationButtonEnabled: map.myLocationButtonEnabled,
354360
padding: map.padding,
361+
insetsLayoutMarginsFromSafeArea: map.insetsLayoutMarginsFromSafeArea,
355362
);
356363
}
357364

@@ -379,6 +386,8 @@ class _AppleMapOptions {
379386

380387
final EdgeInsets? padding;
381388

389+
final bool? insetsLayoutMarginsFromSafeArea;
390+
382391
Map<String, dynamic> toMap() {
383392
final Map<String, dynamic> optionsMap = <String, dynamic>{};
384393

@@ -400,6 +409,8 @@ class _AppleMapOptions {
400409
addIfNonNull('myLocationEnabled', myLocationEnabled);
401410
addIfNonNull('myLocationButtonEnabled', myLocationButtonEnabled);
402411
addIfNonNull('padding', _serializePadding(padding));
412+
addIfNonNull(
413+
'insetsLayoutMarginsFromSafeArea', insetsLayoutMarginsFromSafeArea);
403414
return optionsMap;
404415
}
405416

0 commit comments

Comments
 (0)