Flutter 为什么两个集装箱之间有一条白线

Flutter 为什么两个集装箱之间有一条白线,flutter,flutter-layout,Flutter,Flutter Layout,我正在为我的应用程序制作一个抽屉,它在column窗口小部件中有两个容器,这些容器之间似乎有一条线破坏了外观,我已经尝试了上面的容器 margin: EdgeInsets.only(bottom: 0), padding: EdgeInsets.only(bottom: 0), margin: EdgeInsets.only(top: 0), padding: EdgeInsets.only(top: 0), 下面的容器是这个 margin: EdgeInsets.onl

我正在为我的应用程序制作一个抽屉,它在column窗口小部件中有两个容器,这些容器之间似乎有一条线破坏了外观,我已经尝试了上面的容器

  margin: EdgeInsets.only(bottom: 0),
  padding: EdgeInsets.only(bottom: 0),
  margin: EdgeInsets.only(top: 0),
  padding: EdgeInsets.only(top: 0),
下面的容器是这个

  margin: EdgeInsets.only(bottom: 0),
  padding: EdgeInsets.only(bottom: 0),
  margin: EdgeInsets.only(top: 0),
  padding: EdgeInsets.only(top: 0),
但这条线仍然存在。如何删除该行,任何帮助将不胜感激。这是抽屉的代码:

Drawer(
  child: Column(
    children: <Widget>[
      Container(
        height: globals.heightofdevice * 0.30,
        width: double.infinity,
        margin: EdgeInsets.only(bottom: 0),
        padding: EdgeInsets.only(bottom: 0),
        child: Stack(
          children: <Widget>[
            Image.asset(
              './images/drawerbackground.jpg',
              fit: BoxFit.fitWidth,
            ),
            Positioned(
              left: globals.widthofdevice * 0.07,
              bottom: 20,
              child: Text(
                globals.username,
                style: GoogleFonts.quicksand(
                  textStyle: TextStyle(
                    // fontWeight: FontWeight.w700,
                    fontSize: 32,
                    color: Colors.white,
                  ),
                ),
              ),
            )
          ],
        ),
      ),
      Container(
        height: globals.heightofdevice * 0.70,
        margin: EdgeInsets.only(top: 0),
        padding: EdgeInsets.only(top: 0),
        decoration: BoxDecoration(
          gradient: LinearGradient(
            colors: [Colors.redAccent, Colors.white],
            begin: Alignment.bottomCenter,
            end: Alignment.topCenter,
          ),
        ),
        child: Stack(children: <Widget>[
          Image.asset(
            './images/uni.jpg',
            fit: BoxFit.cover,
            width: double.infinity,
          ),
          Column(
            children: <Widget>[
              listTileBuilder(Icons.history, 'History'),
              listTileBuilder(Icons.info_outline, 'About the app'),
              listTileBuilder(Icons.account_circle, 'Logout'),
              listTileBuilder(Icons.exit_to_app, 'Exit'),
            ],
          ),
        ]),
      )
    ],
  ),
)
抽屉(
子:列(
儿童:[
容器(
高度:全局。设备高度*0.30,
宽度:double.infinity,
边距:仅限边集(底部:0),
填充:仅限边设置(底部:0),
子:堆栈(
儿童:[
影像资产(
“./images/drawerbackground.jpg”,
适合:BoxFit.fitWidth,
),
定位(
左:globals.widthofdevice*0.07,
底数:20,
子:文本(
globals.username,
样式:GoogleFonts.quicksand(
textStyle:textStyle(
//fontWeight:fontWeight.w700,
字体大小:32,
颜色:颜色,白色,
),
),
),
)
],
),
),
容器(
高度:全局。设备高度*0.70,
边距:仅限边集(顶部:0),
填充:仅限边集(顶部:0),
装饰:盒子装饰(
梯度:线性梯度(
颜色:[colors.redAccent,colors.white],
开始:对齐.bottomCenter,
结束:对齐。上止点,
),
),
子:堆栈(子:[
影像资产(
“./images/uni.jpg”,
适合:BoxFit.cover,
宽度:double.infinity,
),
纵队(
儿童:[
listTileBuilder(Icons.history,“history”),
listTileBuilder(Icons.info_outline,“关于应用程序”),
listTileBuilder(Icons.account_circle,'Logout'),
listTileBuilder(Icons.exit_至_应用程序“exit”),
],
),
]),
)
],
),
)
从这张图中你可以清楚地看到问题所在


它必须与图像或堆栈有关

另一个例子让我们试试

return Scaffold(
      appBar: new AppBar(
        title: new Text("Drawer"),
      ),
      drawer: Drawer(
        child: Column(
          children: <Widget>[
            Container(
              color: Colors.yellow,
              height: MediaQuery.of(context).size.height * 0.30,
              width: double.infinity,
              child: new Container(
                decoration: BoxDecoration(
                    image: DecorationImage(
                        image: AssetImage("./images/drawerbackground.jpg"), fit: BoxFit.fill)),
                child: new Align(
                  alignment: Alignment.bottomLeft,
                  child: new Padding (
                    padding: EdgeInsets.only(left: 20.0, bottom: 10.0),
                    child: Text(
                      "globals.username",
                      style: TextStyle(color: Colors.white),
                    ),
                  ),
                ),
              ),
            ),
            Container(
              height: MediaQuery.of(context).size.height * 0.70,
              width: double.infinity,
              decoration: BoxDecoration(
                image: DecorationImage(
                    image: AssetImage("./images/uni.jpg"), fit: BoxFit.fill),
                gradient: LinearGradient(
                  colors: [Colors.redAccent, Colors.white],
                  begin: Alignment.bottomCenter,
                  end: Alignment.topCenter,

                ),
              ),
              child: Column(
                children: <Widget>[
                  listTileBuilder(Icons.history, 'History'),
                  listTileBuilder(Icons.info_outline, 'About the app'),
                  listTileBuilder(Icons.account_circle, 'Logout'),
                  listTileBuilder(Icons.exit_to_app, 'Exit'),
                ],
              ),
            )
          ],
        ),
      ),
      body: Container(
        child:  Text('Add Moka'),
        ),
    );
返回脚手架(
appBar:新的appBar(
标题:新文本(“抽屉”),
),
抽屉(
子:列(
儿童:[
容器(
颜色:颜色,黄色,
高度:MediaQuery.of(上下文).size.height*0.30,
宽度:double.infinity,
子容器:新容器(
装饰:盒子装饰(
图像:装饰图像(
图像:AssetImage(“./images/drawerbackground.jpg”),fit:BoxFit.fill),
子:新对齐(
对齐:对齐。左下角,
孩子:新的填充物(
填充:仅限边缘设置(左侧:20.0,底部:10.0),
子:文本(
“globals.username”,
样式:TextStyle(颜色:Colors.white),
),
),
),
),
),
容器(
高度:MediaQuery.of(上下文).size.height*0.70,
宽度:double.infinity,
装饰:盒子装饰(
图像:装饰图像(
图片:AssetImage(“./images/uni.jpg”),fit:BoxFit.fill),
梯度:线性梯度(
颜色:[colors.redAccent,colors.white],
开始:对齐.bottomCenter,
结束:对齐。上止点,
),
),
子:列(
儿童:[
listTileBuilder(Icons.history,“history”),
listTileBuilder(Icons.info_outline,“关于应用程序”),
listTileBuilder(Icons.account_circle,'Logout'),
listTileBuilder(Icons.exit_至_应用程序“exit”),
],
),
)
],
),
),
主体:容器(
子项:文本('Add Moka'),
),
);

问题很可能是您的顶部小部件的图像设置为
fit:BoxFit.fitWidth,
。由于它试图完全填充水平平面,因此一旦填充完毕,它将停止,而不会垂直缩放以覆盖剩余的空白

要使用颜色填充图像未拍摄的容器空间,使其不是白色线条,您可以尝试以下操作(将背景更改为黑色):

或者,要尝试使图像占用容器的所有可用空间,而不管图像的大小和纵横比,您可以更改BoxFit以填充:

Image.asset(
  './images/drawerbackground.jpg',
  fit: BoxFit.fill,  // BoxFit fill
),

这确实有效,您是否使用了MediaQuery.of而不是带有装饰和子项的仅堆栈容器?Globals.heightofdevice取自MediaQuery only更新了我的解决方案,以显示解决问题的方法的代码示例。请尝试一下,看看他们是否解决了问题。谢谢,有没有任何答案可以解决你的问题,或者这个问题还没有解决?