【发布时间】:2020-05-07 01:57:05
【问题描述】:
是否可以在 Flutter 网页中嵌入 Youtube 视频?我尝试使用以下代码将 Youtube 嵌入到我的 Flutter 网站中,但页面上没有出现任何错误消息。
import 'package:flutter_html_view/flutter_html_view.dart';
Container(child: HtmlView(data: """
<iframe src="https://www.youtube.com/embed/xMzkWfIR9Pk" width="560" height="315"></iframe>
""")),
还尝试了此处推荐的解决方案 (WebView in Flutter Web),但这也不起作用。
import 'dart:ui' as ui
//ignore: undefined_prefixed_name
ui.platformViewRegistry.registerViewFactory(
'hello-world-html',
(int viewId) => html.IFrameElement()
..width = '640'
..height = '360'
..src = 'https://www.youtube.com/embed/IyFZznAk69U'
..style.border = 'none');
【问题讨论】:
标签: flutter youtube flutter-web