
上QQ阅读APP看书,第一时间看更新
3.2.6 Drawer
Drawer是抽屉样式的控件,Drawer的子控件中一般使用ListView,第一个元素一般使用DrawerHeader,接下来是ListTile。
简单的Drawer使用代码如下:
class DrawerDemo extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Flutter 实战入门'), ), drawer: Drawer( child: ListView( children: <Widget>[ DrawerHeader( child: Text('头像'), ), ListTile( title: Text("我的"), ), ListTile( title: Text("关于"), ), ListTile( title: Text("主页"), ) ], ), ), ); } }
运行效果如图3-20所示。

图3-20 Drawer效果