答案 0 :(得分:1)
您可以在Row和Container小部件周围加上其他Row
。然后,可以在外部Row
上将MainAxisAlignment
设置为MainAxisAlignment.spaceAround
或MainAxisAlignment.spaceBetween
。这样会在不同的选项之间创建间距。
在一个独立的示例下:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
ColoredBox(color: Colors.grey, text: 'Booked'),
ColoredBox(color: Colors.green, text: 'Available'),
ColoredBox(color: Colors.red, text: 'Selected'),
],),
),
),
);
}
}
class ColoredBox extends StatelessWidget {
final String text;
final Color color;
ColoredBox({this.text, this.color});
@override
Widget build(BuildContext context) {
return Row(children: <Widget>[
Container(
width: 10.0,
height: 10.0,
color: this.color,
),
Text(this.text)
],);
}
}