4

I want to place google_mobile_ads Banner Ad just above or below the BottomNavigationBar in Flutter.

I tried to place the BottomNavigationBar in Container ad add Margin, but there is no option to add 2 children inside the Container.

I tried to add a Column widget inside the BottomNavigationBar but the column goes to the up top of the page.

Any ideas on how I can make a place for google_mobile_ads just above or below the BottomNavigationBar?

I can share the code, but I need advice or guidance or pointers on how it can be achieved.

lepsch
  • 8,927
  • 5
  • 24
  • 44
Purna Satya
  • 153
  • 1
  • 11
  • It's better if you provide a minimum example for us. In the meantime, a Container can only have one child, whereas a column can have many. You should constrain your column so that it does not fill all the page. Something like a container would work. – Raphael Sauer Jan 06 '22 at 20:40
  • Can you suggest how I can constraint the column so that it can stick to the bottom part of the page and not take up the whole page. The body is inside the singlechildscrollview which has a listview builder inside. I will paste the once I am back at my system. – Purna Satya Jan 06 '22 at 21:00

3 Answers3

7

That's how I dealt with it

bottomNavigationBar: Column(
        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.end,
        children: [
          AdvertisementWidget(),
          BottomNavigationBar(),
        ],
      )
Armagan GOK
  • 81
  • 1
  • 7
2

There are many ways to achieve this. one would be to separate your scaffold and Ad container like this:

return Column(
    children:[
        Expanded(child: Scaffold(),
        SizedBox(height: 50, child: AdContainer())
    ]
)

another way would be to add it in the bottom nav bar:

bottomNavigationBar: SizedBox(
                         height = 200,
                         child: Column(
                                    children: [
                                        BottomNav(),
                                        AdContainer()
                                    ]
                         )
                     )
Mohamad Bastin
  • 309
  • 2
  • 6
1

Wrap in a column in MaterialApp and expand Scaffold body to fill Ad to the bottom

MaterialApp:
       Column(:[
            Expanded(Scaffold),
            AdWidget,
        ])
Kohls
  • 820
  • 7
  • 19