如何更改导航抽屉的工具栏颜色
How to change the ToolBar Color for the Navigation Drawer
如何更改导航抽屉的工具栏颜色。
只需在您的 listview
小部件中添加 padding: EdgeInsets.all(0.0),
Drawer
小部件
试试这个
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)),
);
}
}
输出
With padding: EdgeInsets.all(0.0),
Without padding: EdgeInsets.all(0.0),
如何更改导航抽屉的工具栏颜色。
只需在您的 listview
小部件中添加 padding: EdgeInsets.all(0.0),
Drawer
小部件
试试这个
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)),
);
}
}
输出
With
padding: EdgeInsets.all(0.0),
Without
padding: EdgeInsets.all(0.0),