Reputation: 722
I have a Flutter fullscreen modal widget with a header, a footer and some content which should be rendered natively for iOS. I know I can host iOS UIView
s in Flutter using Platform Views and I managed to do all the logic to get this working.
My issue is that I need to host a whole view controller within this widget, not only a simple view, and this view controller belongs to a third-party framework.
An option would be implementing the header and footer natively, but this would take a lot of time since this would involve passing lot of data, performing network requests, adding callbacks and so on. I read online that a UIKitViewController
exists, but it can only be created from PlatformViewServices
, which is still a work in progress and should not be used. I didn't manage to find proper documentation online.
Upvotes: 0
Views: 1206
Reputation: 139
I think you can try this.
class NativeView: NSObject, FlutterPlatformView {
private var _vc: UIViewController
init(
frame: CGRect,
viewIdentifier viewId: Int64,
arguments args: Any?,
binaryMessenger messenger: FlutterBinaryMessenger?
) {
_vc = UIViewController()
super.init()
}
func view() -> UIView {
return _vc.view
}
}
Calling _vc.view
will call loadView()
and viewDidLoad()
when view is not initialized yet.
Upvotes: 4