我想在文本"NAME"和"Thashreef"之间留一个空格。所以我使用了填充:EdgeInsets.only(top:10(,在视频教程中它是SsizeBox(height:10(。这两个功能相同吗?
void main()=> runApp(MaterialApp(
home: FirstPage()
));
class FirstPage extends StatelessWidget{
@override
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
backgroundColor: Colors.grey[900],
appBar: AppBar(
title: Text('Ninja ID Card'),
centerTitle: true,
backgroundColor: Colors.grey[850],
elevation: 0.0,
),
body: Padding(
padding: EdgeInsets.fromLTRB(20,30,40,50),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text('NAME',style: TextStyle(
color:Colors.grey,
letterSpacing: 2.0),),
Padding(
padding: const EdgeInsets.only(top:10),
child: Text('Thashreef',
style: TextStyle(
color: Colors.yellowAccent,
letterSpacing:2.0,fontSize: 28.0,fontWeight: FontWeight.bold)),
)
],
),
),
);
}
}```
Padding
和SizedBox
Widgets
是不一样的。
填充用于围绕Widget
,周围或特定侧面都有空间。
SsizeBox 是一种不需要生孩子的Widget
,可以只设置高度或宽度。这意味着它可以用作包含多个子项(如Row
或Column
(的Widgets
内的简单垫片。就像您遵循的教程一样。