I have a third party ios native framework and would like to call it in my Flutter project.
Therefore I would like to write a flutter plugin.
However the framework need a UINavigationController as a parameter and I dont know how to
get the UINavigationController inside my Plugin.swift.
I face the similar situation in android side that I would like to get the activity/context for the android plugin. And fortunately I found the solution in here
Now I am looking for iOS side and want to know how to get UINavigationController in iOS plugin.swift similar to the android side above.
I have tried below code but I cannot get the UINavigationController.
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
if let viewController = UIApplication.shared.windows.first?.rootViewController as? UINavigationController {
// do my stuff
} else {
result(FlutterError(code: "-1", message: "cant convert root view controller", details: nil))
}
}
It always show “cant convert root view controller”.
Thanks




