flutter - 在以下情况下使 appbar 透明
问题描述
伙计们!我正在尝试使这个 AppBar 透明。因为它背后会有背景,但到目前为止我还没有成功。我谢谢大家谢谢!
class _HomePageState extends State<HomePage> {
int index = 0;
Widget build(BuildContext context) {
return Scaffold(
body: show(index),
appBar: AppBar(
backgroundColor: Colors.transparent,
actions: <Widget>[
IconButton(
icon: Icon(Icons.settings),
onPressed: (){},
)
],
),
bottomNavigationBar: Theme(
data: Theme.of(context).copyWith(
canvasColor: Colors.grey[900],
),
child: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
currentIndex: index,
showUnselectedLabels: true,
unselectedItemColor: Colors.white54,
selectedItemColor: Colors.white,
onTap: ((int x) {
setState(() {
index = x;
});
}),
items: [
new BottomNavigationBarItem(
icon: Icon(Icons.home), title: Text("Home")),
new BottomNavigationBarItem(
icon: Icon(Icons.search), title: Text("Search")),
new BottomNavigationBarItem(
icon: Icon(Icons.library_music), title: Text("Library")),
],
),
),
);
}
}
解决方案
Appbar默认有阴影,如果你想要透明的appbar,你还需要添加elevation: 0
到AppBar
删除阴影。
推荐阅读
- amazon-web-services - 如何将亚马逊 S3 存储桶中的文件索引到我的云组织?
- angular - 如何删除 Angular CLI 生成的 SSL 证书
- sql-server - SQL Server 将图像导出到网络驱动器
- jquery - ASP.NET Core Jquery Ajax 发送数组失败
- c# - 无法在 c#.net 中隐藏.ToDateTime“2020 年 2 月 29 日 12:00AM”
- javascript - 使用父状态反应计时器
- javascript - 滚动文本以更改滚动时的固定背景图像
- ios - 如何调用呼叫目录扩展的`beginRequest`?
- javascript - javascript方法中的第二个参数是什么?
- fonts - 占位符内的图标和文本