当我在改变文本的字体大小时,圆头像边距也在变化,为什么会这样?

  • 本文关键字:变化 文本 改变 字体 小时 flutter
  • 更新时间 :
  • 英文 :


当我改变文本的字体大小时,圆头像边距也在变化,为什么会这样?

法典:

home: Scaffold(
backgroundColor: Colors.teal,
body: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
CircleAvatar(
radius: 50.0,
backgroundImage: AssetImage('images/pic.jpg'),
),
Text(
'michael scofield',
style: TextStyle(
fontFamily: 'pacifico',
fontSize: 40.0,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
],
),
),
)

发生这种情况是因为您没有使用 crossAxisAlignment。它被自动设置为中心作为默认值。使用以下代码将其设置为左对齐。

Scaffold(
backgroundColor: Colors.teal,
body: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CircleAvatar(
radius: 50.0,
backgroundImage: AssetImage('images/pic.jpg'),
),
Text(
'michael scofield',
style: TextStyle(
fontFamily: 'pacifico',
fontSize: 60.0,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
],
),
),
)

相关内容

最新更新