Skip to content

Instantly share code, notes, and snippets.

@ryanlid
Created February 2, 2020 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanlid/8a8dca80b872cf0424198498bc95cfee to your computer and use it in GitHub Desktop.
Save ryanlid/8a8dca80b872cf0424198498bc95cfee to your computer and use it in GitHub Desktop.
Drawer 抽屉示例
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Drawer 抽屉示例",
home: Scaffold(
appBar: AppBar(
title: Text('Drawer 抽屉示例'),
),
body: Center(
child: Text('Drawer 抽屉示例'),
),
drawer: Drawer(
child: ListView(
children: <Widget>[
UserAccountsDrawerHeader(
accountName: Text('一只大象'),
accountEmail: Text('one@daxiang.com'),
// 设置当前用户的头像
currentAccountPicture: CircleAvatar(
backgroundImage: NetworkImage(
"https://static.lidong.me/upload/XjGwvaVAI.png",
)),
onDetailsPressed: () {},
// 设置其它用户头像
otherAccountsPictures: <Widget>[
Container(
child: Image.network(
"https://static.lidong.me/upload/c7QdErvcb.png",
),
)
],
),
// 导航栏菜单
ListTile(
leading: CircleAvatar(
child: Icon(Icons.color_lens),
),
title: Text("个性装扮"),
),
ListTile(
leading: CircleAvatar(
child: Icon(Icons.photo),
),
title: Text("我的相册"),
),
ListTile(
leading: CircleAvatar(
child: Icon(Icons.wifi),
),
title: Text("免流量特权"),
),
],
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment