flutter之AppBar

举报
青年码农 发表于 2022/08/24 22:35:34 2022/08/24
【摘要】 1 AppBar 一个典型的AppBar,带有标题、操作和溢出的下拉菜单。AppBar  Material风格应用栏,有工具栏和其他的Widget构成 应用栏通常用于Scaffold.appBar属性,该属性将应用栏放置在屏幕顶部的固定高度小部件中。对于可滚动的应用栏,请参阅SliverAppBar,它将一个...

1 AppBar

一个典型的AppBar,带有标题、操作和溢出的下拉菜单。AppBar  Material风格应用栏,有工具栏和其他的Widget构成 应用栏通常用于Scaffold.appBar属性,该属性将应用栏放置在屏幕顶部的固定高度小部件中。对于可滚动的应用栏,请参阅SliverAppBar,它将一个AppBar嵌入到一个条子中,以便在CustomScrollView中使用。

2 构造函数


   
  1. AppBar({
  2. Key key,
  3. this.leading,
  4. this.automaticallyImplyLeading = true,
  5. this.title,
  6. this.actions,
  7. this.flexibleSpace,
  8. this.bottom,
  9. this.backgroundColor,
  10. this.brightness,
  11. this.iconTheme,
  12. this.textTheme,
  13. this.primary = true,
  14. this.centerTitle,
  15. this.titleSpacing = NavigationToolbar.kMiddleSpacing,
  16. this.toolbarOpacity = 1.0,
  17. this.bottomOpacity = 1.0,
  18. })

3 常用属性

3.1 tleading:在标题前面显示的一个控件,在首页通常显示应用的 logo;在其他界面通常显示为返回按钮


   
  1. leading: IconButton(
  2. icon: Icon(Icons.menu),
  3. onPressed: () {},
  4. ),

3.2 title:标题,通常显示为当前界面的标题文字,可以放组件

title: "AppBarWidget",
  

3.3 actions:通常使用 IconButton 来表示,可以放按钮组


   
  1. actions: <Widget>[
  2. IconButton(
  3. icon: Icon(Icons.search),
  4. onPressed: () {},
  5. ),
  6. IconButton(
  7. icon: Icon(Icons.more_horiz),
  8. onPressed: () {},
  9. )
  10. ],

3.4 bottom:通常放 tabBar,标题下面显示一个 Tab 导航栏

bottom:<Widget>[],
  

3.5 backgroundColor:导航背景颜色

backgroundColor: Colors.redAccent,
  

3.6 centerTitle: 标题是否居中显示,默认值根据不同的操作系统,显示方式不一样

centerTitle: true
  

文章来源: blog.csdn.net,作者:NMGWAP,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/NMGWAP/article/details/125067243

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。