Home > Mobile >  How to place banner ad on top of App Bar in Flutter?
How to place banner ad on top of App Bar in Flutter?

Time:08-27

How can I place a banner ad on the top of the top App Bar in Flutter? I have the banner ad at the bottom of the bottom app bar as shown below. I want to move it to the top, so that it becomes the first widget of the screen.

enter image description here

CodePudding user response:

Try prefferedSizeAppbar widget and increase the app bar height and use you banner.

CodePudding user response:

You can use PreferredSize or flexibleSpace,

PreferredSize
appBar: PreferredSize(
    preferredSize: Size.fromHeight(120), // change height of ads as you like
    child: Container(
        child: // here is ads
    )
)

or

flexibleSpace
appBar: AppBar(
    toolbarHeight: 120, // Set this appbar height
    flexibleSpace: Container(
        child: Text("this is add"),  // make container of your ads
    ),
    title: Text('Material App Bar'),
),
  • Related