我想让元素留在它们之间的空间,如果它们没有溢出,但如果它们确实包装了它们.
这是我的代码:
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
if (constraints.maxWidth <= MediaQuery.of(context).size.width * 0.5) {
return Wrap(
children: [
Text("very long text"),
Text("2"),
],
);
} else {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween
children: [
Text("short text"),
Text("2"),
],
);
}
},
);
即使文本很小,它也总是在换行中输入