我目前正试图调整我的扑布局,以我的主题。我想颜色的顶部酒吧在相同的颜色作为侧NavBar(抽屉)。
我为这两个元素使用颜色/背景色Theme.of(context).colorScheme.primaryContainer
,但是,两者的显示方式不同。(见插图)
我如何才能防止这种情况?我想让顶部栏的颜色抽屉x1c 0d1x
我的代码:SideMenu:
@override
Widget build(BuildContext context) {
return Drawer(
backgroundColor: Theme.of(context).colorScheme.primaryContainer,
elevation: 10,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(0),
bottomRight: Radius.circular(0),
),
),
child: SingleChildScrollView(
child: Column(children: [
DrawerHeader(
padding: EdgeInsets.zero,
child: Image.asset("lib/images/logo.png",),
),
DrawerListTile(title: "Dashboard", icon: Icons.dashboard, onTap: () => onMemberPressed(0)),
DrawerListTile(title: "Member", icon: Icons.group, onTap: () => onMemberPressed(1)),
...
])),
);
}
}
字符串
会员管理屏幕:
@override
Widget build(BuildContext context) {
return SafeArea(
child: Column(
children: [
Container(
color: Theme.of(context).colorScheme.primaryContainer,
padding: const EdgeInsets.all(10),
child: Row(
children: [
if (!Responsive.isDesktop(context))
IconButton(
icon: Icon(Icons.menu,
color: Theme.of(context).colorScheme.primary),
onPressed: Scaffold.of(context).openDrawer,
),
if (!Responsive.isDesktop(context))
const SizedBox(
width: 20,
),
if (!Responsive.isMobile(context))
Text(title,
style: TextStyle(
color: Theme.of(context).colorScheme.onPrimary,
fontSize: 20,
fontWeight: FontWeight.bold)),
if (!Responsive.isMobile(context))
Spacer(flex: Responsive.isDesktop(context) ? 2 : 1),
const SizedBox(
width: 20,
),
Expanded(
flex: 2,
child: TextField(
controller: searchController,
decoration: InputDecoration(
fillColor: Theme.of(context).colorScheme.secondary,
filled: true,
hintText: "Search",
hintStyle: TextStyle(
color: Theme.of(context).colorScheme.onSecondary,
),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10)),
borderSide: BorderSide.none,
),
suffixIcon: InkWell(
onTap: () {
setState(() {
filter = searchController.text;
});
},
child: Container(
padding: EdgeInsets.all(10),
margin: EdgeInsets.symmetric(horizontal: 7),
decoration: BoxDecoration(
color: Theme.of(context)
.colorScheme
.primaryContainer,
borderRadius:
BorderRadius.all(Radius.circular(10)),
),
child: Icon(
Icons.search,
color: Theme.of(context).colorScheme.primary,
),
),
),
),
),
),
],
),
),
],
),
);
}
型
2条答案
按热度按时间cwdobuhd1#
将Drawertheme设置为:
字符串
qjp7pelc2#
解决方案是,小部件的油漆轻与他们的海拔。所以我设置的海拔顶部酒吧为10以及。