Skip to content

Instantly share code, notes, and snippets.

@yizems
Last active May 16, 2020 13:30
Show Gist options
  • Save yizems/a47408eb9dffebf337a3dbe2df221db0 to your computer and use it in GitHub Desktop.
Save yizems/a47408eb9dffebf337a3dbe2df221db0 to your computer and use it in GitHub Desktop.
Flutter Web js 获取 registerViewFactory 创建的页面元素
// ignore:undefined_prefixed_name
ui.platformViewRegistry.registerViewFactory('someViewType', (int viewId) {
final wrapper = DivElement()
..style.width = '100%'
..style.height = '100%';
/// FIX:
/// https://github.com/flutter/flutter/issues/40080
/// https://github.com/flutter/flutter/issues/50452
/// document.getElementsByTagName('flt-platform-view')[0].shadowRoot.getElementById('plotly_div_id_')
final script = ScriptElement();
script.appendText(
'embedpano({swf:"viewer/krpano.swf", xml:"viewer/krpano.xml", target:"pano", html5:"auto", mobilescale:1.0, passQueryParameters:true});');
// final div = DivElement()
// ..id = 'pano'
var div = (querySelector('#pano') as DivElement)
..contentEditable = 'true'
..style.width = '100%'
..style.backgroundColor = 'red'
..style.height = '100%';
div.append(script);
wrapper.append(div);
return wrapper;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment