Skip to content

Commit 401f317

Browse files
committed
Code cleanup for defaultEmbedBuilderWeb
1 parent 4e1bc30 commit 401f317

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

example/lib/universal_ui/universal_ui.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,26 +59,26 @@ Widget defaultEmbedBuilderWeb(
5959
),
6060
);
6161
case BlockEmbed.videoType:
62-
final youtubeID = YoutubePlayer.convertUrlToId(node.value.data);
63-
var embedUrl = node.value.data;
64-
65-
if (youtubeID != null) {
66-
embedUrl =
67-
'https://www.youtube.com/embed/${YoutubePlayer.convertUrlToId(embedUrl)}';
62+
var videoUrl = node.value.data;
63+
if (videoUrl.contains('youtube.com') || videoUrl.contains('youtu.be')) {
64+
final youtubeID = YoutubePlayer.convertUrlToId(videoUrl);
65+
if (youtubeID != null) {
66+
videoUrl = 'https://www.youtube.com/embed/$youtubeID';
67+
}
6868
}
6969

7070
UniversalUI().platformViewRegistry.registerViewFactory(
71-
embedUrl,
71+
videoUrl,
7272
(id) => html.IFrameElement()
7373
..width = MediaQuery.of(context).size.width.toString()
7474
..height = MediaQuery.of(context).size.height.toString()
75-
..src = embedUrl
75+
..src = videoUrl
7676
..style.border = 'none');
7777

7878
return SizedBox(
7979
height: 500,
8080
child: HtmlElementView(
81-
viewType: embedUrl,
81+
viewType: videoUrl,
8282
),
8383
);
8484
default:

0 commit comments

Comments
 (0)