在此示例中,我们将学习如何实现从左侧滑动的侧面菜单?这是一个简单抽屉的示例(厦门网站建设只是通过flutter create修改了默认项目设置):
如何实现从左侧滑动的侧边菜单
以下是实现侧面菜单的示例,该侧面菜单在flutter应用程序中从左侧滑动:
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
|
import ‘package:flutter/material.dart’;
void main() {
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: ‘Flutter Demo’,
home: new MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text(‘TestProject’),
),
drawer: new Drawer(
child: new ListView(
children: <Widget> [
new DrawerHeader(child: new Text(‘Header’),),
new ListTile(
title: new Text(‘First Menu Item’),
onTap: () {},
),
new ListTile(
title: new Text(‘Second Menu Item’),
onTap: () {},
),
new Divider(),
new ListTile(
title: new Text(‘About’),
onTap: () {},
),
],
)
),
body: new Center(
child: new Text(
‘Center’,
),
),
);
}
}
|