using a drawer in flutter code example
Example 1: flutter drawer
Scaffold(
drawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
DrawerHeader(
child: Text("Header")),
ListTile(
title: Text("Home"))
]),
),
);
Example 2: app drawer in flutter
class navigationDrawer extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
createDrawerHeader(),
createDrawerBodyItem(
icon: Icons.home,text: 'Home'),
createDrawerBodyItem(
icon: Icons.account_circle,text: 'Profile'),
createDrawerBodyItem(
icon: Icons.event_note,text: 'Events'),
Divider(),
createDrawerBodyItem(
icon: Icons.notifications_active,text: 'Notifications'),
createDrawerBodyItem(
icon: Icons.contact_phone,text: 'Contact Info'),
ListTile(
title: Text('App version 1.0.0'),
onTap: () {},
),
],
),
);
}
}
Example 3: add a drawer flutter
Drawer(
// Add a ListView to the drawer. This ensures the user can scroll
// through the options in the drawer if there isn't enough vertical
// space to fit everything.
child: ListView(
// Important: Remove any padding from the ListView.
padding: EdgeInsets.zero,
children: [
DrawerHeader(
decoration: BoxDecoration(
color: Colors.blue,
),
child: Text('Drawer Header'),
),
ListTile(
title: Text('Item 1'),
onTap: () {
// Update the state of the app.
// ...
},
),
ListTile(
title: Text('Item 2'),
onTap: () {
// Update the state of the app.
// ...
},
),
],
),
);