Skip to content

Commit 3ca9a0c

Browse files
committed
Fix video aspect ratio
The `ChewieController` doesn't use the aspect ratio from the container, leading to incorrect padding around the element. Fixes Sub6Resources#264
1 parent 77bd460 commit 3ca9a0c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/src/replaced_element.dart

+5-2
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,11 @@ class VideoContentElement extends ReplacedElement {
249249

250250
@override
251251
Widget toWidget(RenderContext context) {
252+
final double _width = width ?? (height ?? 150) * 2;
253+
final double _height = height ?? (width ?? 300) / 2;
252254
return Container(
253-
width: width ?? (height ?? 150) * 2,
254-
height: height ?? (width ?? 300) / 2,
255+
width: _width,
256+
height: _height,
255257
child: Chewie(
256258
controller: ChewieController(
257259
videoPlayerController: VideoPlayerController.network(
@@ -264,6 +266,7 @@ class VideoContentElement extends ReplacedElement {
264266
looping: loop,
265267
showControls: showControls,
266268
autoInitialize: true,
269+
aspectRatio: _width / _height,
267270
),
268271
),
269272
);

0 commit comments

Comments
 (0)