Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 12 additions & 20 deletions darwin/mapkit_flutter/Sources/mapkit_flutter/MapKitPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,19 @@ import AppKit

@objc(MapKitPlugin)
@MainActor
public final class MapKitPlugin: NSObject, FlutterPlugin {
public final class MapKitPlugin: NSObject, @preconcurrency FlutterPlugin {
private static let viewType = "dev.mapkit.flutter/map_view"

public nonisolated static func register(with registrar: FlutterPluginRegistrar) {
// Plugin registration runs on the main thread; the factory and view
// host are main-actor isolated. macOS's GeneratedPluginRegistrant
// calls this from a nonisolated context, so assume isolation here.
// The registrar hand-off shares that guarantee: it never leaves the
// main thread, it just isn't Sendable-provable.
nonisolated(unsafe) let registrar = registrar
MainActor.assumeIsolated {
let factory = MapKitViewFactory(withRegistrar: registrar)
#if os(iOS)
registrar.register(
factory,
withId: viewType,
gestureRecognizersBlockingPolicy: FlutterPlatformViewGestureRecognizersBlockingPolicyWaitUntilTouchesEnded
)
#elseif os(macOS)
registrar.register(factory, withId: viewType)
#endif
}
public static func register(with registrar: FlutterPluginRegistrar) {
let factory = MapKitViewFactory(withRegistrar: registrar)
#if os(iOS)
registrar.register(
factory,
withId: viewType,
gestureRecognizersBlockingPolicy: FlutterPlatformViewGestureRecognizersBlockingPolicyWaitUntilTouchesEnded
)
#elseif os(macOS)
registrar.register(factory, withId: viewType)
#endif
}
}
Loading