你應該用FittedBox
包裹你的Row
,這將使它們只消耗它們需要的空間,所以你的代碼應該是這樣的:
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Wrap(
children: [
FittedBox(
child: Row(
children: [
Text('a'),
],
),
),
FittedBox(
child: Row(
children: [
Text('b'),
],
),
),
],
);
}
}
你的輸出將是這樣的: ![你的輸出將是這樣的](https://stackoom.com/link/aHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9Jd3l3ci5wbmc=)