You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HtmlElementView has no onPlatformViewCreated callback. This callback is primarily important to learn the viewId of the created view, for instance, to open the platform channel. The underlying code has its own callback in place but the call doesn't get propagated to the upper level.
muhleder, jing-pei and DavidSonNguyenDavidSonNguyenDavidSonNguyen
I went on with my code and realized that the problem is deeper than just asking for a new feature. The fact that there is no callback on creation means that there is no place to call any initialization from. When I create a new HtmlElementView, it's still premature to call any initialization because the actual PlatformViewLink isn't created yet, it will only come alive later in the build(), thus I can't find it in the DOM yet at that moment.
class HtmlElementView extends StatelessWidget {
final String viewType;
final PlatformViewCreatedCallback onPlatformViewCreated;
final dynamic creationParams;
const HtmlElementView({Key key, @required this.viewType, this.onPlatformViewCreated, this.creationParams})
: assert(viewType != null),
assert(kIsWeb, 'HtmlElementView is only available on Flutter Web.'),
super(key: key);
@override
Widget build(BuildContext context) => PlatformViewLink(
viewType: viewType,
onCreatePlatformView: _createHtmlElementView,
surfaceFactory: (BuildContext context, PlatformViewController controller) => PlatformViewSurface(
controller: controller,
gestureRecognizers: const <Factory<OneSequenceGestureRecognizer>>{},
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
),
);
_HtmlElementViewController _createHtmlElementView(PlatformViewCreationParams params) {
final _HtmlElementViewController controller = _HtmlElementViewController(params.id, viewType);
controller._initialize().then((_) {
params.onPlatformViewCreated(params.id);
onPlatformViewCreated(params.id); //!!!
});
return controller;
}
}
In addition to the extra fields that make it on par with AndroidView and UIKitView, this actually means a single line added, marked with //!!!. It also makes way to provide the creation parameters that would be very comfortable, just like with the other platform counterparts. I don't really understand why you left that out in the first place, you had to work around this omission in your own plugins like video_player. :-)
@hterkelsen It seems that something is worked on with this control (eg. PlatformViewController.clearFocus() changed to async). Couldn't this be possibly a time to check this out? It's just a simple callback providing feature parity with other platforms, nothing dangerous. :-)
Activity
deakjahn commentedon May 6, 2020
I went on with my code and realized that the problem is deeper than just asking for a new feature. The fact that there is no callback on creation means that there is no place to call any initialization from. When I create a new
HtmlElementView
, it's still premature to call any initialization because the actualPlatformViewLink
isn't created yet, it will only come alive later in thebuild()
, thus I can't find it in the DOM yet at that moment.deakjahn commentedon May 7, 2020
The optimal solution would be as simple as:
In addition to the extra fields that make it on par with
AndroidView
andUIKitView
, this actually means a single line added, marked with//!!!
. It also makes way to provide the creation parameters that would be very comfortable, just like with the other platform counterparts. I don't really understand why you left that out in the first place, you had to work around this omission in your own plugins likevideo_player
. :-)yjbanov commentedon May 7, 2020
@hterkelsen can you please triage this?
deakjahn commentedon Jul 13, 2020
@hterkelsen It seems that something is worked on with this control (eg. PlatformViewController.clearFocus() changed to async). Couldn't this be possibly a time to check this out? It's just a simple callback providing feature parity with other platforms, nothing dangerous. :-)
RaghuMudem commentedon Feb 19, 2021
Any solution for this, onPlatformViewCreated for HtmlElementView ?
18 remaining items