0
点赞
收藏
分享

微信扫一扫

浅识Flutter 基本组件Scaffold的 drawer属性 app左侧侧边栏

浅识Flutter 基本组件Scaffold的 drawer属性 app左侧侧边栏

drawer属性用于定义应用程序的左侧侧边栏,通常与List View组件组合使用。该属性值为Drawer类型组件
Drawer常用属性和功能

属性名属性值类型默认值说明
childWidget类型设置左侧侧边栏徐亚放置的可显示对象,常用ListView进行实现
elevationdouble16设置Materia Design中组件的Z坐标顺序

Drawer组件可以用DrawerHeader和UserAccountsDrawerHeader这两个组件添加头部效果。它们的属性如下表。

DrawerHeader的常用属性及功能

属性名类型功能说明
decorationDecoration设置头部区域的装饰效果.通常用来设置背景颜色或者背景图片
curveCurve设置切换动画效果.如果decoration发生了变化,则会使用curve设置的变化曲线和duration设置的动画时间来做一个切换动画
childwidget设置头部区城显示的组件
paddingEdgeInsetsGeometry设置头部区城组件的 padding值.如果 child为 null 的话,则这个值无效
marginEdgeInsetsGeometry设置头部区域四周的间隙

UserAccountsDraweHeader的常用属性及功能

属性名类型说明
marginEdgelnsctsGcometry设置头部区城四周的间隙
decorationDecoration设置头部区城的装饰效果.通常用来设置背景颜色或者背景图片
currentAccountPictureWidget设置当前用户的头像
otherAccountsPicturesList设置当前用户其他账号的头像
accountNameWidget设置当前用户名
accountEmailWidget设置当前用户Email
onDetailsPressedVoidCallBack设置当accountName或accountEmail被点击的时所触发的回调函数
/*设置左侧侧边栏*/
    drawer:Drawer(
      child: ListView(
        children: <Widget>[
          ListTile(leading: Icon(Icons.account_balance),title: Text("紫禁城"),subtitle:  Text('紫禁城的风水养人'),),
          ListTile(leading: Icon(Icons.account_box_rounded),title: Text("雍正"),subtitle:  Text('往事暗沉不可追,来日之路光明灿烂'),),
          ListTile(leading: Icon(Icons.accessibility_new),title: Text("皇后"),subtitle:  Text('死生不复相见'),),
        ],
      ),
    ),

在这里插入图片描述

举报

相关推荐

0 条评论