简体   繁体   English

如何在 Flutter 的 App Bar 顶部放置横幅广告?

[英]How to place banner ad on top of App Bar in Flutter?

How can I place a banner ad on the top of the top App Bar in Flutter?如何在 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.我想将它移到顶部,使其成为屏幕的第一个小部件。

在此处输入图像描述

Try prefferedSizeAppbar widget and increase the app bar height and use you banner.尝试 prefferedSizeAppbar 小部件并增加应用栏高度并使用您的横幅。

You can use PreferredSize or flexibleSpace ,您可以使用PreferredSizeflexibleSpace

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'),
),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM