Skip to content

Commit 632e597

Browse files
authored
Merge pull request #501 from tneotia/fix/video-aspect-ratio
Fix video aspect ratio black bars
2 parents 4b0898f + 640fd02 commit 632e597

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

lib/src/replaced_element.dart

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -292,20 +292,23 @@ class VideoContentElement extends ReplacedElement {
292292
Widget toWidget(RenderContext context) {
293293
final double _width = width ?? (height ?? 150) * 2;
294294
final double _height = height ?? (width ?? 300) / 2;
295-
return Container(
296-
child: Chewie(
297-
controller: ChewieController(
298-
videoPlayerController: VideoPlayerController.network(
299-
src.first ?? "",
295+
return AspectRatio(
296+
aspectRatio: _width / _height,
297+
child: Container(
298+
child: Chewie(
299+
controller: ChewieController(
300+
videoPlayerController: VideoPlayerController.network(
301+
src.first ?? "",
302+
),
303+
placeholder: poster != null
304+
? Image.network(poster)
305+
: Container(color: Colors.black),
306+
autoPlay: autoplay,
307+
looping: loop,
308+
showControls: showControls,
309+
autoInitialize: true,
310+
aspectRatio: _width / _height,
300311
),
301-
placeholder: poster != null
302-
? Image.network(poster)
303-
: Container(color: Colors.black),
304-
autoPlay: autoplay,
305-
looping: loop,
306-
showControls: showControls,
307-
autoInitialize: true,
308-
aspectRatio: _width / _height,
309312
),
310313
),
311314
);

0 commit comments

Comments
 (0)