flutter - 删除列元素之间的奇怪空间
问题描述
我有以下布局:
我想删除上框和按钮之间的空间,因此两者似乎都在同一个框中。
代码:
Column(
children: [
// RAW CONTENT
ConstrainedBox(
constraints: BoxConstraints(
maxWidth: double.infinity,
maxHeight: MediaQuery.of(context).size.height *
_PREVIEW_MAX_HEIGHT_RATIO),
child: Container(
padding: EdgeInsets.only(
left: MARGIN_LAT,
top: MARGIN_TOP,
right: MARGIN_LAT),
child: Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.black38),
borderRadius: BorderRadius.only(
topLeft: _ROUND_BORDER,
topRight: _ROUND_BORDER)),
child: Center(child: Text(_displayValue))),
),
),
// CONTENT BUTTONS
Container(
padding: EdgeInsets.only(
left: MARGIN_LAT, top: 0, right: MARGIN_LAT),
child: Row(
children: [
Expanded(
child: RaisedButton(
padding: EdgeInsets.zero,
child: Text(_static.translate(
context, 'result_contentButton_raw')),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
bottomLeft: _ROUND_BORDER)),
onPressed: () {}),
),
Expanded(
child: RaisedButton(
padding: EdgeInsets.zero,
child: Text(_static.translate(context,
'result_contentButton_displayValue')),
shape: ContinuousRectangleBorder(),
onPressed: () {}),
),
Expanded(
child: RaisedButton(
padding: EdgeInsets.zero,
child: Text(_static.translate(
context, 'result_contentButton_copy')),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
bottomRight: _ROUND_BORDER)),
onPressed: () {}),
)
],
),
),
],
),
有没有办法做到这一点?谢谢。
解决方案
您注意到的边距是因为RaisedButton 小部件上 materialTapTargetSize的默认值。
要删除它,请将其更改为MaterialTapTargetSize.shrinkWrap,如下所示:
Expanded(
child: RaisedButton(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
padding: EdgeInsets.zero,
child: Text("This is an other text"),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
bottomLeft: _ROUND_BORDER
)
),
onPressed: () {}
),
)
推荐阅读
- c# - 通过 ajax 发布请求接收图像 接收该图像的类应该是什么
- elasticsearch - kibana 中不显示时间戳数据
- go - 在结构中表示可选 time.Time 的惯用方式
- go - 读入一个结构会覆盖另一个
- c++ - 在可变参数函数中转发特定范围的参数
- java - 如何以编程方式在 intellij idea 中设置全局 gradle 设置(gradle vm 选项)?
- c++ - windows下使用cmake编译glfw
- c# - C# VSTO for Outlook - 触发 VBA 宏的按钮
- css - 元素上 chrome 背景中分辨率为 1920x1080 的 CSS
- javascript - JS json数组比较数组并删除重复项