diff --git a/ios/Classes/MapView/AppleMapController.swift b/ios/Classes/MapView/AppleMapController.swift index 85e7a98..c86d68c 100644 --- a/ios/Classes/MapView/AppleMapController.swift +++ b/ios/Classes/MapView/AppleMapController.swift @@ -58,8 +58,13 @@ public class AppleMapController: NSObject, FlutterPlatformView { return contentView } + deinit { + channel.setMethodCallHandler(nil) + } + private func setMethodCallHandlers() { - channel.setMethodCallHandler({ [unowned self] (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in + channel.setMethodCallHandler({ [weak self] (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in + guard let self = self else { return } if let args: Dictionary = call.arguments as? Dictionary { switch(call.method) { case "annotations#update":