Flutter 大小框和填充。。这有什么区别吗?
我想在文本“NAME”和“thashref”之间留一个空格。所以我使用padding:EdgeInsets.only(顶部:10),在视频教程中它是SizedBox(高度:10)。这两种功能相同吗Flutter 大小框和填充。。这有什么区别吗?,flutter,dart,cross-platform,Flutter,Dart,Cross Platform,我想在文本“NAME”和“thashref”之间留一个空格。所以我使用padding:EdgeInsets.only(顶部:10),在视频教程中它是SizedBox(高度:10)。这两种功能相同吗 void main()=> runApp(MaterialApp( home: FirstPage() )); class FirstPage extends StatelessWidget{ @override Widget build(BuildContext context
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)),
)
],
),
),
);
}
}```
void main()=>runApp(MaterialApp(
主页:首页()
));
类FirstPage扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
//TODO:实现构建
返回脚手架(
背景颜色:颜色。灰色[900],
appBar:appBar(
标题:文本(“忍者身份证”),
标题:对,
背景颜色:颜色。灰色[850],
标高:0.0,
),
主体:填充物(
填充物:LTRB(20,30,40,50)的边缘设置,
子:列(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
Text('NAME',style:TextStyle(
颜色:颜色。灰色,
字母间距:2.0),),
填充物(
填充:仅限常量边集(顶部:10),
child:Text('thashref',
样式:TextStyle(
颜色:Colors.yellowAccent,
字体间距:2.0,字体大小:28.0,字体重量:字体重量。粗体),
)
],
),
),
);
}
}```
填充
和大小框
小部件
是不同的
用于将小部件
包围在其周围或特定侧面
是一个小部件
,不需要孩子,只需设置高度或宽度即可。这意味着它可以用作小部件
中的一个简单分隔符,该小部件包含多个子项,如行
或列
。就像你所遵循的教程一样