小编mil*_*dia的帖子

无法在标题文本小部件上应用 AppBar titleTextStyle

我无法使用 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)

appbar dart flutter

2
推荐指数
2
解决办法
1121
查看次数

标签 统计

appbar ×1

dart ×1

flutter ×1