flutter - 使appbar与body颜色一致
问题描述
我需要使用 的属性AppBar
,但我需要应用栏与正文颜色相同。好像没有appbar。我对 body 和 appBar 使用了相同的颜色,但 appBar 的颜色更深!
材料应用程序代码:
class MyApp extends StatelessWidget {
const MyApp();
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'AppName',
theme: ThemeData(
backgroundColor: Color(pagesBackgroundColor),
appBarTheme: AppBarTheme(
color: Color(pagesBackgroundColor),
),
),
home: const HomePage(),
);
}
}
主页代码:
class HomePage extends StatelessWidget {
const HomePage();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Color(pagesBackgroundColor),
title: Text(
"What's up!",
style: TextStyle(color: Colors.black),
),
elevation: 0.0,
),
body: Column(),
);
}
}
解决方案
将应用栏颜色设置为透明:
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
title: Text(
"What's up!",
style: TextStyle(color: Colors.black),
),
elevation: 0.0,
),
body: Column(),
);
推荐阅读
- oracle - 如果没有返回该值的数据,则返回参数值?
- html - React useState() doesn't update value synchronously
- grafana - 如何为注释创建后端 Grafana 插件?
- serial-port - Synacess PowerUSB 的 C# 串行接口
- video - 如果我用相同的比特率连续两次 ffmpeg 编码会发生什么
- css - 是否可以通过 grid-template-columns 定义隐藏内容为空的列?
- c - “inc”中的内容包括项目中的文件夹?
- c - 为什么函数调用只传递第一个参数
- java - 关闭 Android 弹出菜单
- r - For 循环不起作用,但循环的每个组件都有效