-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Open
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projecta: platform-viewsEmbedding Android/iOS views in Flutter appsEmbedding Android/iOS views in Flutter appsd: api docsIssues with https://api.flutter.dev/Issues with https://api.flutter.dev/frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.platform-iosiOS applications specificallyiOS applications specificallyteam-iosOwned by iOS platform teamOwned by iOS platform teamtriaged-iosTriaged by iOS platform teamTriaged by iOS platform team
Description
The view API is declared here:
https://github.com/flutter/engine/blob/master/shell/platform/darwin/ios/framework/Headers/FlutterPlatformViews.h#L22
After we implemented the unobstructed platform view. We need the embedded view to be cached. As a result, the platform view implementer must not create a new instance of the platform view every frame.
It was never a good practice anyway as it reduces performance.
One example of good implementation of platform view would be:
class UIRectView: NSObject, FlutterPlatformView {
let embedded_view: UIView
init(_ frame: CGRect) {
embedded_view = UIView(frame: frame)
embedded_view.backgroundColor = UIColor.cyan
}
func view() -> UIView {
return embedded_view
}
}A bad example would be:
class UIRectView: NSObject, FlutterPlatformView {
func view() -> UIView {
let embedded_view = UIView(frame: frame)
embedded_view.backgroundColor = UIColor.cyan
return embedded_view;
}
}We should document the same in the public API.
steffenmllr, tusharr1996 and guopeng1994
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projecta: platform-viewsEmbedding Android/iOS views in Flutter appsEmbedding Android/iOS views in Flutter appsd: api docsIssues with https://api.flutter.dev/Issues with https://api.flutter.dev/frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.platform-iosiOS applications specificallyiOS applications specificallyteam-iosOwned by iOS platform teamOwned by iOS platform teamtriaged-iosTriaged by iOS platform teamTriaged by iOS platform team