Home > Mobile >  Flutter: Force Container child to fit parent width
Flutter: Force Container child to fit parent width

Time:08-24

I'm putting AdMob banner ads in my Flutter app.

I have a container (with the background color set to red, as seen below), and the banner ad is a child of this container. I want to force the banner ad to zoom in enough to cover the red background. In other words, the container child will fill all of the container.

How to do that?

P.S.: I know about native ads and responsive size, but I don't wanna use these. Gotta stick to the banner ad.

enter image description here

CodePudding user response:

you can use media queries kindly look following example

var size,height,width;
size = MediaQuery.of(context).size;
    height = size.height;
    width = size.width;

it will fit your window size

CodePudding user response:

You might be able to use a FittedBox, wrap it around the Admob widget, and set its fit property to something like BoxFit.cover.

  • Related