PhoenixAppBar class
AppBar组件,基于AppBar封装。为了解决原生的AppBar对Leading宽度的限制
在1.21版本之后,Flutter放开了宽度的限制https://github.com/flutter/flutter/blob/flutter-1.21-candidate.0/packages/flutter/lib/src/material/app_bar.dart
布局规则: leading是左侧显示的内容 title是中间显示的内容 action是右侧显示的内容 呈现的依然是AppBar,优化点在于:第一 title可以传入String 第二 action和leading 封装了快捷使用
用户如果想自定义 使用效果完全可以传入appbar的属性
布局步骤:同appbar默认的布局 先leading、后action,最后title
首先,计算leading的宽度 外部传入则可以leadingWidth 则已外部传入为主
该组件为[DoubleLeading]和[BackLeading]提供了计算
leading默认的大小是[AppBarConfig.leadingSize],
[DoubleLeading]的大小是 但是Leading的宽度的2倍+间距
leadingWidth默认宽度为BrnAppBarConfig.leadingSize
如果传入的leading是完全自定义的Widget,可以自行设置leadingWidth
其次,摆放action
最后,对齐title
组件支持两种显示模式深色和浅色。 通过AppBar.brightness
属性设置,
深色Brightness.dark模式,背景色是黑色,icon和文字颜色是白色。
浅色Brightness.light模式,背景色是白色,icon和文字颜色是黑色。
如果使用默认的BackLeading和AppBarTitle
BkAppBar中的文字颜色和backLeading可自动随着AppBar.brightness
变化。
组件提供了默认的返回leading,如果不需要默认的leading可以设置automaticallyImplyLeading为false 默认的leading,提供了默认的返回Navigator.pop(context), 如果是native打开的话,可能需要单独处理,否则会出现白屏
其他属性同AppBar本身的含义
显示:返回按钮、Appbar示例文本 PhoenixAppBar( title: 'Appbar示例', )
显示:自定义leading、tab切换、自定义action PhoenixAppBar( leading: BrnBackLeading(), title: Row( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children:
相关组件如下:
- BackLeading, 自定义leading,单个文本或按钮
DoubleLeading
, 自定义leading,两个文本或按钮AppBarTitle
, 自定义title,纯文本展示IconAction
, 自定义action,显示iconTextAction
, 自定义action,纯文本展示BarBottomDivider
, appbar与其他元素的分割线,同BrnLine
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- PreferredSize
- PhoenixAppBar
Constructors
- PhoenixAppBar({Key? key, Widget? leading, bool showLeadingDivider = false, dynamic title, dynamic actions, Color? backgroundColor, PreferredSizeWidget? bottom, double elevation = 0, bool automaticallyImplyLeading = true, double toolbarOpacity = 1.0, double bottomOpacity = 1.0, Alignment titleAlignment = Alignment.center, Widget? flexibleSpace, VoidCallback? backLeadCallback, bool? showDefaultBottom, AppBarConfig? themeData, double? leadingWidth, Color? shadowColor, ShapeBorder? shape, IconThemeData? iconTheme, IconThemeData? actionsIconTheme, bool excludeHeaderSemantics = false, bool primary = true, SystemUiOverlayStyle? systemOverlayStyle, double? titleSpacing})
- PhoenixAppBar.buildSearchResultStyle({Key? key, String? title, Color? backgroundColor, PreferredSizeWidget? bottom, bool showLeadingDivider = true, Widget? flexibleSpace, VoidCallback? backLeadCallback, bool? showDefaultBottom = true, AppBarConfig? themeData, double? leadingWidth, Color? shadowColor, ShapeBorder? shape, IconThemeData? iconTheme, IconThemeData? actionsIconTheme, bool excludeHeaderSemantics = false, bool primary = true, SystemUiOverlayStyle? systemOverlayStyle, double? titleSpacing})
Properties
- actions → dynamic
-
为了方便业务使用,可以设置为Widget或者List
final
- actionsIconTheme → IconThemeData?
-
final
- automaticallyImplyLeading → bool
-
是否自动添加Leading实现
final
- backgroundColor → Color?
-
以下属性都对应于AppBar中的属性
详细介绍可以查阅AppBar的文档
final
- backLeadCallback → VoidCallback?
-
默认处理了返回按钮,flutter的pop,如果是native打开的话,可能需要单独处理,否则会出现白屏
backLeadCallback是默认的处理回调
DefaultLeadingCallBack 也可以通过改方法参数 设置统一的返回处理,该参数是静态的
final
- bottom → PreferredSizeWidget?
-
final
- bottomOpacity → double
-
final
- child → Widget
-
The widget below this widget in the tree.
finalinherited
- elevation → double
-
final
- excludeHeaderSemantics → bool
-
final
- flexibleSpace → Widget?
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- iconTheme → IconThemeData?
-
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- leading → Widget?
-
导航栏左侧活动区域,在为null且
automaticallyImplyLeading为true时默认赋值为
BrnBackLeading
final - leadingWidth → double?
-
final
- preferredSize → Size
-
The size this widget would prefer if it were otherwise unconstrained.
no setteroverride
- primary → bool
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shadowColor → Color?
-
final
- shape → ShapeBorder?
-
final
- showDefaultBottom → bool?
-
是否显示默认的eeeeee分割线,默认显示,可以设置为不显示
final
- showLeadingDivider → bool
-
final
- systemOverlayStyle → SystemUiOverlayStyle?
-
final
- themeData → AppBarConfig?
-
final
- title → dynamic
-
AppBar标题,必须是String或者Widget类型
为String时,会使用BrnAppBarTitle来加载title
final
- titleAlignment → Alignment
-
final
- titleSpacing → double?
-
final
- toolbarOpacity → double
-
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited