首页 > 解决方案 > 如何摆脱appbar和body之间的界限?

问题描述

我有一个应用栏,在正文中有一个专栏。我想以一种你不知道应用栏结束和列开始的方式来实现它。为此,我将应用栏的高度设置为零,并且应用栏和列中的小部件的背景颜色相同。然而,似乎有一条线将两者分开,我就是无法摆脱。

这是代码:

Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: SizedBox(),
        backgroundColor: Colors.blue,
        title: Text("Profile"),
        centerTitle: true,
        elevation: 0,
      ),
      body: Column(
        children: [
          SizedBox(
            height: 240,
            child: Stack(
              children: [
                ClipPath(
                  clipper: CustomShape(),
                  child: Container(
                    height: 150,
                    color: Colors.blue,
                  ),
                )
              ],
            ),
          ),
        ],
      ),
    );
  }

这是线/分隔线的样子:

在此处输入图像描述

我想过摆脱 appbar 并只放置一个容器来代替它,但这似乎有点麻烦,所以我想在应用之前检查是否有任何其他我可以考虑的解决方案。

标签: flutter

解决方案


为您的脚手架提供与您的 appBar 颜色相同的背景颜色。在我的图片中,颜色是 orange.200,我得到了这些图片,在你的情况下,使用蓝色作为代码。

Scaffold(backgroundColor: Colors.blue,
appBar: AppBar(
        leading: SizedBox(),
        backgroundColor: Colors.blue,
        title: Text("Profile"),
        centerTitle: true,
        elevation: 0,
      ),

在脚手架的主体中,根据需要为容器着色。

这是没有设置脚手架背景颜色: 在此处输入图像描述

这是一个脚手架背景: 在此处输入图像描述


推荐阅读