Flutter AppBar组件参数详情说明列表

26 min read
参数 说明 默认值
leading 左侧小部件 null
automaticallyImplyLeading 是否自动显示导航按钮 true
title 标题 null
actions 右侧小部件列表 null
flexibleSpace 可以展开的区域,显示在标题和标签之间 null
bottom 底部小部件 null
elevation 阴影的高度,值越大阴影越明显 4.0
scrolledUnderElevation 滚动到底部后阴影的高度,值越大阴影越明显 elevation 相同
notificationPredicate 决定是否向树上传递通知 defaultScrollNotificationPredicate
shadowColor 阴影的颜色 透明
surfaceTintColor 表面的颜色(暂未使用) null
shape 边框形状 矩形
backgroundColor 背景色 null
foregroundColor 前景色 null
brightness 明暗主题 Brightness.light
iconTheme 图标的样式 与当前主题相关
actionsIconTheme 右侧小部件图标的样式 与当前主题相关
textTheme 文本的样式 与当前主题相关
primary 是否为 app 的主导航条 true
centerTitle 标题是否居中 false
excludeHeaderSemantics 是否排除 header 的语义,比如 AppBar 中的 title 会被自动包裹为一个语义 widget,如果你要自定义的话可以使用该属性 false
titleSpacing 标题的间距 NavigationToolbar.kMiddleSpacing
toolbarOpacity 工具栏的不透明度 1.0
bottomOpacity 底部区域的不透明度 1.0
toolbarHeight 工具栏的高度 kToolbarHeight
leadingWidth 左侧小部件的宽度 null
backwardsCompatibility 是否开启兼容模式,该属性已弃用,不再使用 false
leading 在标题前面显示的widget null
automaticallyImplyLeading 是否自动添加返回按钮 true
title 标题显示的widget null
actions 在标题后面显示的widget null
flexibleSpace 在标题和tabs之间显示的空间,如果有的话 null
bottom 在标题下方显示的widget,通常是TabBar null
elevation 阴影高度 4.0
scrolledUnderElevation 滚动内容是否遮挡阴影 null
notificationPredicate 在扩展FlexibleSpace时是否要收到ScrollNotification通知的回调 defaultScrollNotificationPredicate
shadowColor 阴影颜色 null
surfaceTintColor 表面颜色 null
shape 边框的形状 矩形边框
backgroundColor AppBar背景颜色 ThemeData.primaryColor
foregroundColor 前景颜色,如文本、按钮的颜色 ThemeData.brightness == Brightness.dark ? Colors.white : Colors.black87
brightness AppBar的亮度模式 null
iconTheme AppBar上图标的主题样式 null
actionsIconTheme AppBar上操作图标的主题样式 null
textTheme AppBar上文本的主题样式 null
primary 是否使用应用程序的主题 true
centerTitle 标题是否居中显示 false
excludeHeaderSemantics 是否排除标题语义 false
titleSpacing 标题与侧边的间距 NavigationToolbar.kMiddleSpacing
toolbarOpacity toolbar的透明度 1.0
bottomOpacity bottom widget的透明度 1.0
toolbarHeight toolbar的高度 kToolbarHeight
leadingWidth leading widget的宽度 null
backwardsCompatibility 是否启用向后兼容模式 false
toolbarTextStyle toolbar上文本的主题样式 null
titleTextStyle 标题文本的主题样式 null
systemOverlayStyle 系统覆盖样式 null