Flutter基础widgets教程-CupertinoNavigationBar篇

时间:2022-07-26
本文章向大家介绍Flutter基础widgets教程-CupertinoNavigationBar篇,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

1 CupertinoNavigationBar

iOS风格的导航栏. 通常和CupertinoPageScaffold一起使用

2 构造函数

CupertinoNavigationBar({
    Key key,
    this.leading,
    this.automaticallyImplyLeading = true,
    this.automaticallyImplyMiddle = true,
    this.previousPageTitle,
    this.middle,
    this.trailing,
    this.border = _kDefaultNavBarBorder,
    this.backgroundColor,
    this.brightness,
    this.padding,
    this.actionsForegroundColor,
    this.transitionBetweenRoutes = true,
    this.heroTag = _defaultHeroTag,
})

3 常用属性

3.1 leading:导航栏左侧组件,leading优先级高于previousPageTitle

leading: Icon(Icons.arrow_back),

3.2 automaticallyImplyLeading:是否显示左边组件

automaticallyImplyLeading : true,

3.3 automaticallyImplyMiddle:是否显示中间组件

automaticallyImplyMiddle : true,

3.4 previousPageTitle:导航栏左侧组件的右边的文本

previousPageTitle : "返回",

3.5 middle:导航栏中间组件

middle: Text("标题"),

3.6 trailing:导航栏右侧组件

trailing: Image.asset(
    "lib/assets/sample/image.jpg", 
    width: 25.0, 
    height: 25.0
),

3.7 backgroundColor:背景色

backgroundColor: Color(0xfff1f1f1),

3.8 padding:内边距

padding: EdgeInsets.symmetric(vertical: 20.0,horizontal: 10.0),

3.9 actionsForegroundColor:左侧默认组件和左侧组件右边文本的颜色

actionsForegroundColor: Colors.red,