【问题标题】:How to remove the small line below Appbar?Appbar下面的小线怎么去掉?
【发布时间】:2020-06-13 00:40:37
【问题描述】:

Flutter 1.12.13+hotfix.8

Appbar 正下方有一条细线。你知道如何摆脱它吗?

代码:

return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        backgroundColor: Colors.blue,
        elevation: 0.0,
        actions: <Widget>[
          FlatButton(
            onPressed: () async {
              await _authService.signOut();
            },
            child: Icon(
              Icons.exit_to_app,
              color: Colors.white,
            ),
          ),
        ],
      ),
      body: Container(
        height: MediaQuery.of(context).size.height,
        width: MediaQuery.of(context).size.width,
        color: Colors.blue),
);

【问题讨论】:

  • 我试过你的代码,但没有得到你说的任何一行,你能分享你的完整代码吗?
  • @HardikTalaviya,刚刚添加了“body”中的容器代码。顺便说一句,我在 Android 上,直接在设备上(不是模拟器)
  • 我也在模拟器和设备上运行你的代码,但AppBar下方没有细线。

标签: flutter


【解决方案1】:

将脚手架背景颜色指定为与您的 AppBar 背景颜色相同的颜色将解决问题(在您的情况下,以下代码) 要为应用程序的其余部分提供您想要的颜色,您可以在包含主体的容器的主体颜色中使用它

return Scaffold(
  backgroundColor: Colors.blue,//changed background color of scaffold
  appBar: AppBar(
    backgroundColor: Colors.blue,
    elevation: 0.0,
    actions: <Widget>[
      FlatButton(
        onPressed: () async {
          await _authService.signOut();
        },
        child: Icon(
          Icons.exit_to_app,
          color: Colors.white,
        ),
      ),
    ],
  ),
  body: Container(
    height: MediaQuery.of(context).size.height,
    width: MediaQuery.of(context).size.width,
    color: Colors.blue),
);

【讨论】:

    【解决方案2】:

    我在 web、iphone 模拟器、android 模拟器和我的 android 手机中尝试了你的代码,没有得到任何白色细线。我现在正在研究颤振测试版。也许你的问题可以通过升级颤振或切换频道来解决。

    【讨论】:

    • 我使用的是1.12.13+hotfix.8版本。
    【解决方案3】:

    你可以试试 appbar 的海拔属性为 0.0

    AppBar(
    elevation: 0.0,
    ),
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-08
      • 1970-01-01
      • 2016-05-27
      • 2014-08-05
      • 2016-11-10
      • 2021-11-03
      • 1970-01-01
      • 2018-09-13
      相关资源
      最近更新 更多