Sou*_*Dev 9 android-appbarlayout flutter flutter-appbar flutter-theme material3
在我的应用程序栏中,标题显示为白色文本,但图标是深灰色或其他颜色。我也想让图标变成白色。
但图标主题中的颜色没有任何效果!
直接添加到 AppBar 时不会...
Scaffold(
appBar: AppBar(automaticallyImplyLeading: false,
actionsIconTheme: IconThemeData(color: Colors.white),
iconTheme: IconThemeData(color: Colors.white),
Run Code Online (Sandbox Code Playgroud)
而且也不在主题中...
appBarTheme: AppBarTheme(
backgroundColor: Colors.blue,
foregroundColor: Colors.white,
actionsIconTheme: IconThemeData(color: Colors.white),
iconTheme: IconThemeData(color: Colors.white),
),
Run Code Online (Sandbox Code Playgroud)
我想让主题发挥作用!无法在图标上单独设置颜色。
我究竟做错了什么?Material 3 真的准备好投入生产了吗?
谢谢!
注意:这是材料 3 的问题!在材质 2 中,一切都按预期进行!
我已经测试了您的代码,一切似乎都有效,您确定没有向 提供 null 吗onPressed?这样可能是disabled
child: Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
actionsIconTheme: IconThemeData(color: Colors.white),
iconTheme: IconThemeData(color: Colors.white),
title: const Text('Screen A'),
actions: [
IconButton(
icon: Icon(Icons.add),
onPressed: () {},
),
const IconButton(
icon: Icon(Icons.add),
onPressed: null,
)
],
),
Run Code Online (Sandbox Code Playgroud)
@编辑
在 Material3 中也适用 - 您确定不覆盖图标主题吗?
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
useMaterial3: true,
primarySwatch: Colors.blue,
),
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
actionsIconTheme: IconThemeData(color: Colors.white),
iconTheme: IconThemeData(color: Colors.white),
title: const Text('Screen A'),
actions: [
IconButton(
icon: Icon(Icons.add),
onPressed: () {},
),
const IconButton(
icon: Icon(Icons.add),
onPressed: null,
)
],
),
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
你是对的 - 它不能正常工作:
根据文档Material3 for IconButton 正在为 Flutter 进行中
| 归档时间: |
|
| 查看次数: |
1996 次 |
| 最近记录: |