最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Flutter BoxFix.cover does not cover but stretch the video - Stack Overflow

matteradmin8PV0评论
 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 its no point in using 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:45
  • Yeah that is what I have. if I don't have one of them then it did not work – chichi Commented Nov 16, 2024 at 22:43
  • 1 chek the below answer: here FittedBox expands to the available space while its child (with VideoPlayer) takes the size of the asset you are showing - this is the case where FittedBox can scale its child – pskink Commented Nov 17, 2024 at 7:40
Add a comment  | 

1 Answer 1

Reset to default 1

Does 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),
      ),
    ),
  ),
),
Post a comment

comment list (0)

  1. No comments so far