drawer widget 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: flutter screen hidden drawer dont show on all pages

class MyDrawer extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Drawer(...);
  }
}
---------------------------------------------------------
And then when using it in each page:

Scaffold(
  drawer: MyDrawer(...),
  ...
)

Example 3: app drawer in flutter

Widget createDrawerHeader() {
 return DrawerHeader(
     margin: EdgeInsets.zero,
     padding: EdgeInsets.zero,
     decoration: BoxDecoration(
         image: DecorationImage(
             fit: BoxFit.fill,
             image:  AssetImage('images/bg_header.jpeg'))),
     child: Stack(children: <Widget>[
       Positioned(
           bottom: 12.0,
           left: 16.0,
           child: Text("Welcome to Flutter",
               style: TextStyle(
                   color: Colors.white,
                   fontSize: 20.0,
                   fontWeight: FontWeight.w500))),
     ]));
}

Example 4: app drawer in flutter

Widget createDrawerBodyItem(
   {IconData icon, String text, GestureTapCallback onTap}) {
 return ListTile(
   title: Row(
     children: <Widget>[
       Icon(icon),
       Padding(
         padding: EdgeInsets.only(left: 8.0),
         child: Text(text),
       )
     ],
   ),
   onTap: onTap,
 );
}

Example 5: flutter navigation drawer

Widget _createDrawerItem(    {IconData icon, String text, GestureTapCallback onTap}) {  return ListTile(    title: Row(      children: <Widget>[        Icon(icon),        Padding(          padding: EdgeInsets.only(left: 8.0),          child: Text(text),        )      ],    ),    onTap: onTap,  );}