I am using SwiftFlutterJailbreakDetectionPlugin
and while I am calling method result()
and passing FlutterMethodNotImplemented
in then I am getting error Reference to var 'FlutterMethodNotImplemented' is not concurrency-safe because it involves shared mutable state
import Flutter
import UIKit
import IOSSecuritySuite
public class SwiftFlutterJailbreakDetectionPlugin: NSObject, FlutterPlugin {
public static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel(name: "flutter_jailbreak_detection", binaryMessenger: registrar.messenger())
let instance = SwiftFlutterJailbreakDetectionPlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
}
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
switch call.method {
case "jailbroken":
let check2 = IOSSecuritySuite.amIJailbroken()
result(check2)
break
case "developerMode":
result(IOSSecuritySuite.amIRunInEmulator())
break
default:
result(FlutterMethodNotImplemented)
}
}
}
Use Preconcurrency Conformance. This is a new feature of Swift 6. The whole idea with this one is to provide a simple and safe way to deal with protocol-isolation mismatches. It tells the compiler yes, actually, my isolated type can conform to this non-isolated protocol.
use @preconcurrency
before the import Flutter
as shown below
@preconcurrency import Flutter
Note: in my case, it worked.