【问题标题】:How to change the color of the back button in a CupertinoNavigationBar in Flutter如何在 Flutter 的 CupertinoNavigationBar 中更改后退按钮的颜色
【发布时间】:2019-09-06 18:25:16
【问题描述】:

我想在我的 Flutter 应用中更改后退按钮的颜色。

这是我目前拥有的:Screenshoot

我想将颜色从浅蓝色更改为白色。我在网上搜索过,但一无所获。这是我的代码(注意我的按钮是自动创建的)

@override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      navigationBar: CupertinoNavigationBar(
        heroTag: 'menupage',
        transitionBetweenRoutes: false,
        middle: Text(
          'Menu Page',
          style: kSendButtonTextStyle,
        ),
      ),

提前非常感谢!

【问题讨论】:

    标签: flutter flutter-cupertino


    【解决方案1】:

    我通过设置 CupertinoTextThemeData 解决了...

    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return CupertinoApp(
          theme: CupertinoThemeData(
            primaryColor:
                Colors.white, //change color of the BOTTOM navbar icons when selected
            textTheme: CupertinoTextThemeData(
              primaryColor:
                  Colors.white, //change color of the TOP navbar icon
    

    感谢卢卡斯为我指明了正确的方向

    【讨论】:

      【解决方案2】:

      例子

      actionsForegroundColor: Colors.white in CupertinoNavigationBar

      去做

      return  CupertinoPageScaffold(
            navigationBar: CupertinoNavigationBar(actionsForegroundColor: Colors.white,
              heroTag: 'menupage',
              transitionBetweenRoutes: false,
              middle: Text(
                'Menu Page',
                style: TextStyle(),
              ),
            ), child: Text(''),
          );
      

      【讨论】:

      • 谢谢,但它对我不起作用。澄清:我希望顶部栏上的蓝色箭头变为白色
      • 这是我在文档中读到的:actionsForegroundColor → 颜色导航栏中前导和尾随小部件的文本和图标的默认颜色。 [...] @Deprecated('使用 CupertinoTheme 和 primaryColor 传播颜色'),最终
      • actionsForegroundColor: Colors.white 放入CupertinoNavigationBar?这是留白箭头
      • 我做到了,但它并没有改变箭头的颜色。问题可能是我的导航栏位于 cupertinoTabView 和 CupertinoTabScaffold 内吗?
      • 这不适用于颤振 2.0,不适用于 CupertinoNavigationBar 中的此类参数
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-07
      • 1970-01-01
      • 2020-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多