0

如何更改导航抽屉的工具栏颜色。

4

1 回答 1

1

只需在小部件内添加padding: EdgeInsets.all(0.0),您的小部件listviewDrawer

尝试这个

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.stack.imgur.com/K8FFo.jpg?s=328&g=1',
          placeholder: (context, url) => CircularProgressIndicator(), //<= ends here
          errorWidget: (context, url, error) => Icon(Icons.error)),
    );
  }
}

输出

padding: EdgeInsets.all(0.0),

在此处输入图像描述

没有padding: EdgeInsets.all(0.0),

在此处输入图像描述

于 2020-06-24T14:40:27.043 回答