How to resize better_player in flutter?

Viewed 207

i am using the better player package in my flutter project, but i notice that my better player wont follow the size i fixed in my container and i just take up all the width of the screen with a fixed height.

My code looks like this:

return FutureBuilder(
      future: storage.downloadURL(annData.videoPath[index]),
      builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
        if (snapshot.connectionState == ConnectionState.done &&
            snapshot.hasData) {
          return Container(
            width: 200,
            height: 200,
            child: BetterPlayer.network(
              snapshot.data!,
              betterPlayerConfiguration: BetterPlayerConfiguration(
                  aspectRatio: 16 / 9, fit: BoxFit.contain),
            ),
          );
        }
        if (snapshot.connectionState == ConnectionState.waiting) {
          return Loading();
        }
        return Container();
      },
    );

Is there anyway to resize the player ?

I put the player in a container, but the player seems to have an important width and height that cant be override

1 Answers

Try to change the aspect ratio:

betterPlayerConfiguration: BetterPlayerConfiguration(
  aspectRatio: 16 / 9,
  fit: BoxFit.contain
),

to

betterPlayerConfiguration: BetterPlayerConfiguration(
  aspectRatio: 1/1,
  fit: BoxFit.contain
),

Change the aspect ratio to your fit.

Related