Javascript 如何将JS脚本的flatterweb参数传递到html文件(HTMLElement,iframe)参数?
我想在Flatter web应用程序中渲染一个pay小部件,我需要一个唯一的令牌,所以我从Dart调用Iframe来渲染它。但是,我没有找到如何发送参数或调用dart func(仅关于dart func,但这不起作用) 这里我从iframe给HTMLELEMNT打电话Javascript 如何将JS脚本的flatterweb参数传递到html文件(HTMLElement,iframe)参数?,javascript,html,dart,flutter-web,Javascript,Html,Dart,Flutter Web,我想在Flatter web应用程序中渲染一个pay小部件,我需要一个唯一的令牌,所以我从Dart调用Iframe来渲染它。但是,我没有找到如何发送参数或调用dart func(仅关于dart func,但这不起作用) 这里我从iframe给HTMLELEMNT打电话 final html.IFrameElement _iframeElement = html.IFrameElement(); _iframeElement.height = MediaQuery.of(context).
final html.IFrameElement _iframeElement = html.IFrameElement();
_iframeElement.height = MediaQuery.of(context).size.height.toString();
_iframeElement.width = MediaQuery.of(context).size.width.toString();
_iframeElement.src =
'paywall.html';
_iframeElement.style.border = 'none';
_iframeElement.id = 'iframe';
final wrapper = html.DivElement()
..style.width = '100%'
..style.height = '100%';
wrapper.append(_iframeElement);
// ignore: UNDEFINED_PREFIXED_NAME
ui.platformViewRegistry.registerViewFactory(
viewID,
(int viewId) => wrapper,
);
return Scaffold(
body: SizedBox(
height: 500,
child: HtmlElementView(
viewType: viewID,
),
));
请帮助我找到一种方法,从颤振Web中传递2个字符串参数的JS调用dart func
String foo() {
return "ct-2830b393-000f-5000-8000-19466365c438";
}
js.context['foo'] = foo;
final html.IFrameElement _iframeElement = html.IFrameElement();
_iframeElement.height = MediaQuery.of(context).size.height.toString();
_iframeElement.width = MediaQuery.of(context).size.width.toString();
_iframeElement.src =
'paywall.html';
_iframeElement.style.border = 'none';
_iframeElement.id = 'iframe';
final wrapper = html.DivElement()
..style.width = '100%'
..style.height = '100%';
wrapper.append(_iframeElement);
// ignore: UNDEFINED_PREFIXED_NAME
ui.platformViewRegistry.registerViewFactory(
viewID,
(int viewId) => wrapper,
);
return Scaffold(
body: SizedBox(
height: 500,
child: HtmlElementView(
viewType: viewID,
),
));