按照此处的说明,可以通过将 Flutter Web 应用程序包装到iframe元素中来将其嵌入到网页中,例如:
<iframe src="URL"></iframe>
Run Code Online (Sandbox Code Playgroud)
其中 URL 指向 Flutter Web 应用程序的 html。
现在,如果您想根据上下文预先配置 Flutter Web 应用程序,该怎么办 - 使其了解嵌入器中存在的某些外部值(iframe HTML 元素或父网页/窗口)。
也许有一个解决方案可以指示 Flutter 从 iframe 读取数据属性?例如:
<iframe src="URL" data-answer="42"></iframe>
Run Code Online (Sandbox Code Playgroud)
还有其他选择吗?
(更广泛的问题是可嵌入设备和嵌入器之间的双向通信。)