我在ListTile中有这样的一列:
return ListTile(
//contentPadding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 20.0),
leading: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
padding: EdgeInsets.only(right: 12.0),
decoration: BoxDecoration(
border: Border(
right: BorderSide(
width: 1.0,
))),
child: Column(
children: <Widget>[
Text('Hello'),
],
),
)
]),
...more code
}
这不是应该使容器垂直居中吗?我正在标题部分中的列和空格处进行类似的操作,效果很好。
答案 0 :(得分:0)
您可以将其添加到Center小部件中
ListTile(
//contentPadding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 20.0),
leading: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
padding: EdgeInsets.only(right: 12.0),
decoration: BoxDecoration(
border: Border(
right: BorderSide(
width: 1.0,
))),
child: Column(
children: <Widget>[
Text('Hello'),
],
),
)
]),
),
)
答案 1 :(得分:0)
您可以尝试将列包装在容器中并给其固定宽度,如下所示:
leading: Container(
width: 100,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[]),
);