flatter列显示Android中小部件之间的额外空间
列小部件显示连续小部件之间的额外空间,即使使用填充设置为0的简单容器。我尝试过使用SizedBox,将mainAxisSize设置为min,但似乎没有任何效果。 此外,这个问题只出现在Android操作系统中,而不是出现在Web或iOS上 我的代码:flatter列显示Android中小部件之间的额外空间,android,flutter,flutter-layout,flutter-web,Android,Flutter,Flutter Layout,Flutter Web,列小部件显示连续小部件之间的额外空间,即使使用填充设置为0的简单容器。我尝试过使用SizedBox,将mainAxisSize设置为min,但似乎没有任何效果。 此外,这个问题只出现在Android操作系统中,而不是出现在Web或iOS上 我的代码: Scaffold( backgroundColor: Colors.yellow, appBar: AppBar( title: Text(title), ), body: Center( child: Column
Scaffold(
backgroundColor: Colors.yellow,
appBar: AppBar(
title: Text(title),
),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
padding: EdgeInsets.zero,
height: 50,
color: Colors.black,
),
Container(
padding: EdgeInsets.zero,
height: 100,
color: Colors.black,
),
SizedBox(
height: 20,
),
Container(
height: 150,
color: Colors.black,
)
],
),
),
)
脚手架(
背景颜色:Colors.yellow,
appBar:appBar(
标题:文本(标题),
),
正文:中(
子:列(
mainAxisSize:mainAxisSize.min,
mainAxisAlignment:mainAxisAlignment.center,
儿童:[
容器(
填充:EdgeInsets.zero,
身高:50,
颜色:颜色,黑色,
),
容器(
填充:EdgeInsets.zero,
身高:100,
颜色:颜色,黑色,
),
大小盒子(
身高:20,
),
容器(
身高:150,
颜色:颜色,黑色,
)
],
),
),
)
输出:
我将图像放大到右侧,以便更好地显示间隙。两个容器之间出现了一行空格。我在柱子下面放置了另一个150高的容器,以显示完全不透明和空间之间的差异。我已经在Pixel 3 Emulator和OnePlus 6T设备上重新创建了相同的行为
有人能帮我解决这个问题吗。我知道这可以用Stack和Positioned解决,但我希望知道这是不是Flatter SDK中的一个问题,还是一个可修复的小部件行为。这确实是一个非常恼人的效果。虽然我不能告诉你为什么会发生这种情况,只是稍微玩弄一下,但似乎给容器一个带有边框而不是颜色的盒子装饰会移除工件:
Scaffold(
backgroundColor: Colors.yellow,
appBar: AppBar(
title: Text('title'),
),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.black),
color: Colors.black,
),
padding: EdgeInsets.zero,
height: 51,
//color: Colors.black,
),
Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.black),
color: Colors.black,
),
padding: EdgeInsets.zero,
height: 100,
),
Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.black),
color: Colors.black,
),
height: 150,
//color: Colors.black,
)
],
),
),
)
脚手架(
背景颜色:Colors.yellow,
appBar:appBar(
标题:文本(“标题”),
),
正文:中(
子:列(
mainAxisSize:mainAxisSize.min,
mainAxisAlignment:mainAxisAlignment.center,
儿童:[
容器(
装饰:盒子装饰(
边框:边框。全部(颜色:颜色。黑色),
颜色:颜色,黑色,
),
填充:EdgeInsets.zero,
身高:51,
//颜色:颜色,黑色,
),
容器(
装饰:盒子装饰(
边框:边框。全部(颜色:颜色。黑色),
颜色:颜色,黑色,
),
填充:EdgeInsets.zero,
身高:100,
),
容器(
装饰:盒子装饰(
边框:边框。全部(颜色:颜色。黑色),
颜色:颜色,黑色,
),
身高:150,
//颜色:颜色,黑色,
)
],
),
),
)
老实说,我觉得自己像个bug,在下面发布了一个可能的解决方法。