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

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

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

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

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

DrawerHeader的常用属性及功能

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

UserAccountsDraweHeader的常用属性及功能

属性名 类型 说明
margin EdgelnsctsGcometry 设置头部区城四周的间隙
decoration Decoration 设置头部区城的装饰效果.通常用来设置背景颜色或者背景图片
currentAccountPicture Widget 设置当前用户的头像
otherAccountsPictures List 设置当前用户其他账号的头像
accountName Widget 设置当前用户名
accountEmail Widget 设置当前用户Email
onDetailsPressed VoidCallBack 设置当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('死生不复相见'),),
        ],
      ),
    ),

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_43336158/article/details/123535685
今日推荐