我无法使用 AppBar titleTextStyle 更改我的 AppBar 标题文本颜色。我知道我可以通过某些方式设置 AppBar 标题样式,例如在 textWidget 中使用样式或在 AppBar 中设置 textTheme,但我只想知道为什么不能通过设置 titleTextStyle 来更改它。
代码如下。尽管设置了 titleTextStyle 和 foregroundColor,AppBar 标题仍然是白色的。
class MyStatelessWidget extends StatelessWidget {
const MyStatelessWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
foregroundColor: Colors.black,
titleTextStyle: TextStyle(color: Colors.black),
title: const Text('AppBar Color'),),
body: const Center(
child: Text('sample'),
),
);
}
}
Run Code Online (Sandbox Code Playgroud)