Skip to content

Commit a1566f0

Browse files
committed
Merge branch 'pr/41'
2 parents 34c5e7d + d0e8f4c commit a1566f0

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
# Changelog
2-
## 1.2.1
3-
* Fix Fatal error: Attempted to read an unowned reference but the object was already deallocated
42

53
## 1.3.0
64

75
* Animate marker position changes instead of removing and re-adding
6+
* Fix Fatal error: Attempted to read an unowned reference but the object was already deallocated
7+
* Fixed an issue where onCameraMove was not invoked by double-tapping
8+
* Added insetsLayoutMarginsFromSafeArea
9+
810
## 1.2.0
911

1012
* Added a `markerAnnotationWithHue()` and `pinAnnotationWithHue()` method to allow custom marker/pin colors
13+
1114
## 1.1.0
1215

1316
* Added Annotation zIndex
1417
* Added posibility to take snapshots of the map
18+
1519
## 1.0.3
1620

1721
* Fixes an issue where mapController.moveCamera would animate the camera transition

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/AppleMapController.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Foundation
99
import MapKit
1010

1111
public class AppleMapController: NSObject, FlutterPlatformView {
12+
var contentView: UIView
1213
var mapView: FlutterMapView
1314
var registrar: FlutterPluginRegistrar
1415
var channel: FlutterMethodChannel
@@ -25,6 +26,11 @@ public class AppleMapController: NSObject, FlutterPlatformView {
2526
self.mapView = FlutterMapView(channel: channel, options: options)
2627
self.registrar = registrar
2728

29+
// To stop the odd movement of the Apple logo.
30+
self.contentView = UIScrollView()
31+
self.contentView.addSubview(mapView)
32+
mapView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
33+
2834
self.initialCameraPosition = args["initialCameraPosition"]! as! Dictionary<String, Any>
2935

3036
super.init()
@@ -49,7 +55,7 @@ public class AppleMapController: NSObject, FlutterPlatformView {
4955
}
5056

5157
public func view() -> UIView {
52-
return mapView
58+
return contentView
5359
}
5460

5561
private func setMethodCallHandlers() {

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)