1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| import 'package:flutter/material.dart';
class DrawerDemoPage extends StatefulWidget { @override State<StatefulWidget> createState() => new _DrawerDemoPageState(); }
class _DrawerDemoPageState extends State<DrawerDemoPage> { @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar(title: new Text('Drawer Demo'),), drawer: new Drawer( child: DrawerBuilder.buildDrawer(context), ), ); } }
class DrawerBuilder { static Widget buildDrawer(BuildContext context) { return new ListView(padding: const EdgeInsets.only(), children: <Widget>[ _drawerHeader(), new ClipRect( child: new ListTile( leading: new CircleAvatar(child: new Text("A")), title: new Text('Android / iOS'), onTap: () { Navigator.pop(context); }, ), ), new ListTile( leading: new CircleAvatar(child: new Text("H")), title: new Text('Home Page'), subtitle: new Text("http://www.appblog.cn"), onTap: () => {}, ), new AboutListTile( icon: new CircleAvatar(child: new Text("Ab")), child: new Text("About"), applicationName: "Test", applicationVersion: "1.0", applicationIcon: new Image.asset( "images/avatar.jpg", width: 64.0, height: 64.0, ), applicationLegalese: "applicationLegalese", aboutBoxChildren: <Widget>[ new Text("BoxChildren"), new Text("http://www.appblog.cn") ], ), ]); }
static Widget _drawerHeader() { return new UserAccountsDrawerHeader( accountName: new Text( "Joe.Ye", style: HStyle.titleNav(), ), accountEmail: new Text( "yezhou@yezhou.org", style: HStyle.bodyWhite(), ), currentAccountPicture: new CircleAvatar( backgroundImage: new AssetImage("images/avatar.jpg"), ), onDetailsPressed: () {}, otherAccountsPictures: <Widget>[ new CircleAvatar( backgroundImage: new AssetImage("images/gift.jpg"), ), ], ); } }
class HStyle { static titleNav() { return new TextStyle(fontWeight: FontWeight.w500, fontSize: 20.0, color: Colors.white); }
static bodyWhite() { return new TextStyle(fontWeight: FontWeight.w500, fontSize: 14.0, color: Colors.white); } }
|