flutter - How to set align right in table with Flutter
问题描述
I'm using flutter table. I would like to set numbers align right.(or center)
How can I make them locate?
I would like to header center. numbers to right.
Container(
margin: EdgeInsets.all(8.0),
width: double.infinity,
decoration: BoxDecoration(border: Border.all(width: 1.0)),
child: Table(
columnWidths: {
0: FlexColumnWidth(1),
1: FlexColumnWidth(1),
2: FlexColumnWidth(4),
3: FlexColumnWidth(1),
4: FlexColumnWidth(1),
5: FlexColumnWidth(1),
6: FlexColumnWidth(1),
},
border: TableBorder.all(),
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
children: <TableRow>[
TableRow(children: <Widget>[
Container(
padding: EdgeInsets.all(2.0),
child: Text('G',
style: TextStyle(fontWeight: FontWeight.bold)),
),
Container(
padding: EdgeInsets.all(2.0),
child: Text('A',
style: TextStyle(fontWeight: FontWeight.bold)),
),
]
),
TableRow(children: <Widget>[
Container(
padding: EdgeInsets.all(2.0),
child: Text('2'),
),
Container(
padding: EdgeInsets.all(2.0),
child: Text('FW'),
),
]
)
Too much code, then I wrote some of codes. Please take a look.
解决方案
有alignment: Alignment.center
里面Container
,
Container(
alignment: Alignment.center,
padding: EdgeInsets.all(2.0),
child: Text('G',
style: TextStyle(fontWeight: FontWeight.bold)),
),
推荐阅读
- java - 有什么方法可以提高效率/减少循环数量?
- javascript - 有没有办法在其他功能之前执行更新面板的更新
- javascript - 如何在传单中设置 geoJSON FeatureCollection 的样式?
- ruby-on-rails - 是否可以使用 dotenv 将 JSON 文件存储到 ENV 变量中?
- php - 如何破译正则表达式?
- excel - 有没有办法锁定单个单元格(不是整个 Excel 工作表)以防止格式化?
- javafx - 将控制器添加到我的 FXML 时如何修复错误
- django - 处理从 python 请求库接收到的数据以在模板中显示它
- c - 如何自动初始化函数指针数组?
- laravel - vuejs 中的 Axios 有时使用 wamp 给我一个错误