SizedBox(
height: context.height,
width: context.width,
child: FittedBox(
fit: BoxFit.cover,
child: SizedBox(
height: context.height,
width: context.width,
child: VideoPlayer(videoC.value!))),
I have this and it does not fit the box but just squeeze the video into fit in that height and width. How can I make it cover the Sizedbox?
SizedBox(
height: context.height,
width: context.width,
child: FittedBox(
fit: BoxFit.cover,
child: SizedBox(
height: context.height,
width: context.width,
child: VideoPlayer(videoC.value!))),
I have this and it does not fit the box but just squeeze the video into fit in that height and width. How can I make it cover the Sizedbox?
Share Improve this question asked Nov 16, 2024 at 15:32 chichichichi 3,3187 gold badges37 silver badges74 bronze badges 3 |1 Answer
Reset to default 1Does this work for you with the video_player
plugin?
SizedBox.expand(
child: FittedBox(
fit: BoxFit.cover,
child: ListenableBuilder(
listenable: _videoController,
builder: (context, _) => SizedBox(
width: _videoController.value.size?.width ?? 0,
height: _videoController.value.size?.height ?? 0,
child: VideoPlayer(_videoController),
),
),
),
),
FittedBox
if both parent and child of it have the same size, are you sure you pasted the correct code? – pskink Commented Nov 16, 2024 at 15:45FittedBox
expands to the available space while its child (withVideoPlayer
) takes the size of the asset you are showing - this is the case whereFittedBox
can scale its child – pskink Commented Nov 17, 2024 at 7:40