只有一个字符的小容器,没有正确居中,填充或不填充设置为0。
如果我减小字体大小,将以居中显示,但默认文本大小为否
Container(
decoration: BoxDecoration(
color: Colors.green,
shape: BoxShape.circle,
),
width: 20.0,
height: 20.0,
alignment: Alignment.center,
padding: EdgeInsets.all(0.0),
child: Text(
'+',
),
)
代码
Container(
width: 40,
height: 40,
alignment: Alignment.center,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.grey,
),
child: RotatedBox(
quarterTurns: 3,
child: Icon(
Icons.expand_less,
color: Colors.white,
),
),
),
FittedBox中,以使其适合容器:
return Container(
decoration: BoxDecoration(
color: Colors.green,
shape: BoxShape.circle,
),
width: 20.0,
height: 20.0,
alignment: Alignment.center,
padding: EdgeInsets.all(0.0),
child: FittedBox(
child:Text('+')
),
);