An End Drawer is similar to a standard Drawer, but it slides in from the right side of the screen instead of the left. It’s useful for secondary menus, filters, settings, or optional features.
Source Code
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('End Drawer Example'),
actions: [
IconButton(
icon: Icon(Icons.menu_open),
onPressed: () {
Scaffold.of(context).openEndDrawer();
},
),
],
),
endDrawer: Drawer(
backgroundColor: Colors.white,
elevation: 16,
child: ListView(
padding: EdgeInsets.zero,
children: [
DrawerHeader(
decoration: BoxDecoration(color: Colors.teal),
child: Text(
'Options',
style: TextStyle(color: Colors.white, fontSize: 24),
),
),
ListTile(
leading: Icon(Icons.info),
title: Text('About'),
onTap: () {
Navigator.pop(context);
},
),
ListTile(
leading: Icon(Icons.help),
title: Text('Help'),
onTap: () {
Navigator.pop(context);
},
),
],
),
),
body: Center(child: Text('Main Content Area')),
);
}
}
Ai Code Analizer
🎨 3. Important Properties Used
| Property | Description |
|---|---|
endDrawer | Widget that appears from the right side when triggered. |
Scaffold.of(context).openEndDrawer() | Manually opens the end drawer via action (like button). |
DrawerHeader | Top header section, usually for branding or info. |
backgroundColor | Background color of the drawer. |
elevation | Adds shadow to create visual depth. |
ListTile | Each item inside the drawer (icon + title + action). |
onTap | Closes the drawer or performs a navigation/action. |
🔧 4. Key Differences from Left Drawer
draweropens from left by default.endDraweropens from right.Requires manual trigger (e.g.,
openEndDrawer()insideAppBaror a button).
