flutterdartflutter-layoutflutter-drawer

How to change the ToolBar Color for the Navigation Drawer


How can I change the toolbar color for the Navigation drawer.


Solution

  • Just add padding: EdgeInsets.all(0.0), in your listview widget inside Drawer widget

    Try this

    class HomePage extends StatefulWidget {
      @override
      _HomePageScreen createState() => _HomePageScreen();
    }
    
    class _HomePageScreen extends State<HomePage> {
      @override
      Widget build(BuildContext context) {
        return  Scaffold(
          appBar:  AppBar(
            title:  Text("Home"),
          ),
          drawer: Drawer(
            child:  ListView(
              padding:  EdgeInsets.all(0.0),
              children: <Widget>[
                 UserAccountsDrawerHeader(
                  accountName:  Text("Nilesh Rathod"),
                  accountEmail:  Text("nilesh@gmail.com"),
                  currentAccountPicture:  CircleAvatar(
                    backgroundColor: Colors.white,
                    child:  Text("Nilu"),
                  ),
                ),
                 ListTile(
                  title:  Text("Home"),
                  trailing:  Icon(Icons.new_releases),
                ),
                 Divider(),
                 ListTile(
                  title:  Text("Profile"),
                  trailing:  Icon(Icons.person),
                  onTap: () => {},
                ),
                 Divider(),
                 ListTile(
                  title:  Text("Tab Layout"),
                  trailing:  Icon(Icons.person),
                  onTap: () => {},
                ),
                 Divider(),
                 ListTile(
                  title:  Text("Comman View Demo"),
                  trailing:  Icon(Icons.person),
                  onTap: () => {},
                ),
                 Divider(),
                 ListTile(
                  title:  Text("Close"),
                  trailing:  Icon(Icons.close),
                  onTap: () => Navigator.of(context).pop(),
                ),
              ],
            ),
          ),
          body:  CachedNetworkImage(
              imageUrl: 'https://i.sstatic.net/K8FFo.jpg?s=328&g=1',
              placeholder: (context, url) => CircularProgressIndicator(), //<= ends here
              errorWidget: (context, url, error) => Icon(Icons.error)),
        );
      }
    }
    

    OUTPUT

    With padding: EdgeInsets.all(0.0),

    enter image description here

    Without padding: EdgeInsets.all(0.0),

    enter image description here