AppBar
AppBar(
{Key key,
Widget leading,
bool automaticallyImplyLeading: true,
Widget title,
List<Widget> actions,
Widget flexibleSpace,
PreferredSizeWidget bottom,
double elevation,
Color shadowColor,
ShapeBorder shape,
Color backgroundColor,
Brightness brightness,
IconThemeData iconTheme,
IconThemeData actionsIconTheme,
TextTheme textTheme,
bool primary: true,
bool centerTitle,
bool excludeHeaderSemantics: false,
double titleSpacing: NavigationToolbar.kMiddleSpacing,
double toolbarOpacity: 1.0,
double bottomOpacity: 1.0,
double toolbarHeight,
double leadingWidth}
)
- 一个app bar由一个工具栏和一些其他潜在的widget组成,如
TabBar和FlexibleSpaceBar.App Bars通常使用IconButtons暴露一个或多个常用操作(actions),可选择在其后使用PopupMenuButton以进行较少的操作(也叫做“溢出菜单”). - AppBar 通常用在Scaffold.appBar属性中,该属性将AppBar作为固定高度的Widget放置在屏幕顶部。有关可滚动的AppBar,详见
SliverAppBar, 它将AppBar嵌入sliver中以在CustomScrollView. - AppBar 显示工具栏Widget(leading,title,actions),高于底部栏
bottom(如果有).bottom通常使用一个TabBar. 如果一个flexibleSpaceWidget被指定,则它堆叠在工具栏和bottomWidget的后面.下图显示了从左到右在工具栏出现上的插槽位置 - AppBar基于
MediaQuery的填充来插入其内容,以避免系统UI入侵.将AppBar包裹在MediaQuery widget中,并调整其填充以使动画流畅. - 如果省略了
leadingwidget,但是AppBar位于带Drawer的Scaffold中是,则插入一个button来打开drawer.除此之外,如果最近的Navigator有任何上一步的路由,则一个BackButton会被替代插入.可以通过将automaticImplyLading设置为false来关闭此行为,这种情况下,一个空的leading widget将导致 中间的titlewidget开始拉升.