NZNavBar class

NZNavBar 是一个多功能、高度可定制的顶部导航栏组件。

它基于 Flutter 的 AppBar 构建,提供了四种常见的业务场景模式:

  1. NZNavBarType.normal - 标准导航栏。
  2. NZNavBarType.search - 带有动画展开搜索功能的导航栏。
  3. NZNavBarType.logo - 品牌展示导航栏。
  4. NZNavBarType.miniApp - 微信小程序风格的导航栏。

示例用法:

// 标准模式
const NZNavBar(title: '首页')

// 搜索模式
NZNavBar.search(
  title: '搜索文档',
  onSearch: () => print('开始搜索'),
)
Inheritance
Implemented types

Constructors

NZNavBar({Key? key, String? title, Widget? titleWidget, Widget? leading, List<Widget>? actions, bool centerTitle = true, double elevation = 0, Color? backgroundColor, Color? foregroundColor})
创建一个标准模式的导航栏
const
创建一个带有 Logo 展示的导航栏
const
NZNavBar.miniApp({Key? key, String? title, VoidCallback? onMiniAppShare, VoidCallback? onMiniAppClose, Widget? leading, double elevation = 0, Color? backgroundColor, Color? foregroundColor})
创建一个小程序风格的导航栏
const
NZNavBar.search({Key? key, String? title, required VoidCallback? onSearch, ValueChanged<String>? onSearchChanged, Widget? leading, List<Widget>? actions, double elevation = 0, Color? backgroundColor, Color? foregroundColor})
创建一个带有搜索功能的导航栏
const

Properties

actions List<Widget>?
右侧操作按钮列表
final
backgroundColor Color?
背景颜色
final
centerTitle bool
标题是否居中显示
final
elevation double
阴影高度
final
foregroundColor Color?
前景颜色(影响文字和图标颜色)
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
leading Widget?
左侧领先组件(通常为返回按钮或菜单图标)
final
logoUrl String?
Logo 图片的 URL 地址(仅在 NZNavBarType.logo 模式下有效)
final
onMiniAppClose VoidCallback?
小程序模式下的关闭按钮点击回调
final
onMiniAppShare VoidCallback?
小程序模式下的分享按钮点击回调
final
onSearch VoidCallback?
点击搜索按钮或提交搜索时的回调
final
onSearchChanged ValueChanged<String>?
搜索框内容变化时的回调
final
preferredSize Size
The size this widget would prefer if it were otherwise unconstrained.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
title String?
导航栏标题文本
final
titleWidget Widget?
自定义标题组件,优先级高于 title
final
type NZNavBarType
导航栏类型
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<NZNavBar>
Creates the mutable state for this widget at a given location in the tree.
override
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