flutter endDrawer
时间: 2024-05-03 19:21:51 浏览: 83
Flutter endDrawer is a widget that is used to display a drawer at the end of the screen. It is similar to the Drawer widget, which is used to display a drawer at the start of the screen. The endDrawer is typically used in applications where the user needs to access additional information or settings.
To use the endDrawer widget, you need to first define the drawer's content in a separate widget, typically a Drawer or a custom widget. Then, you can add the endDrawer widget to your Scaffold widget like this:
```
Scaffold(
appBar: AppBar(
title: Text('My App'),
),
body: Center(
child: Text('Hello World!'),
),
endDrawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
DrawerHeader(
child: Text('Drawer Header'),
decoration: BoxDecoration(
color: Colors.blue,
),
),
ListTile(
title: Text('Item 1'),
onTap: () {
// do something
},
),
ListTile(
title: Text('Item 2'),
onTap: () {
// do something
},
),
],
),
),
);
```
In this example, we have added a Drawer widget to the endDrawer property of the Scaffold widget. The Drawer widget contains a DrawerHeader and two ListTile widgets. When the user swipes from the right edge of the screen or taps on the menu icon in the app bar, the endDrawer will slide into view and display the content of the Drawer widget.
阅读全文