| Scaffold |
appBar: AppBar (title: Text ("标题"))body: 页面内容floatingActionButton: 悬浮按钮bottomNavigationBar: 底部导航drawer: 左侧抽屉backgroundColor: Colors.whiteresizeToAvoidBottomInset: true / false |
| Container |
width: 200height: 200alignment: Alignment.center / topLeft / bottomRightpadding: EdgeInsets.all(10) / symmetric(horizontal:10,vertical:5) / only(left:10)margin: EdgeInsets.all(10) / symmetric(horizontal:10,vertical:5) / only(top:5)color: Colors.bluedecoration: BoxDecoration (颜色、圆角、边框、阴影)child: 子组件 |
| Row |
mainAxisAlignment: start / center / end / spaceBetween / spaceAround / spaceEvenlycrossAxisAlignment: start / center / end / stretchmainAxisSize: max / minchildren: 子组件列表 |
| Column |
mainAxisAlignment: start / center / end / spaceBetween / spaceAround / spaceEvenlycrossAxisAlignment: start / center / end / stretchmainAxisSize: max / minchildren: 子组件列表 |
| Expanded |
flex: 1 / 2 / 3child: 子组件必须放在 Row/Column 内 |
| Stack |
alignment: center / topLeft / topRight / bottomCenterfit: StackFit.loose / expandclipBehavior: Clip.none / hardEdgechildren: 层叠子组件 |
| Text |
data: "显示文字"style: TextStyle(fontSize: 16,color: Colors.black,fontWeight: normal / bold,fontStyle: normal / italic,letterSpacing: 1,height: 1.5,decoration: none / underline / lineThrough)textAlign: left / center / rightmaxLines: 1overflow: ellipsissoftWrap: true |
| TextField |
controller: TextEditingController()decoration: InputDecoration (hintText:"提示",labelText:"标签",border:OutlineInputBorder ())keyboardType: text / number / emailobscureText: true (密码) /falsemaxLength: 20enabled: true / falseonChanged: (value){} |
| Image |
image: NetworkImage(url) / AssetImage(path)width: 100height: 100fit: cover / contain / fill / scaleDownalignment: centercolor: 混合色 |
| ListView |
scrollDirection: vertical / horizontalpadding: EdgeInsets.all(10)shrinkWrap: true / falsephysics: AlwaysScrollable / NeverScrollableitemCount: 数量itemBuilder: 构建列表 |
| ElevatedButton |
onPressed: (){}onLongPress: (){}child: Text ("按钮")style: 背景色、文字色、圆角、padding |
| InkWell |
onTap: 点击onDoubleTap: 双击onLongPress: 长按splashColor: 水波纹颜色child: 子组件 |
| GestureDetector |
onTap: 点击onDoubleTap: 双击onLongPress: 长按onPanUpdate: 拖拽child: 子组件 |
| Padding |
padding: EdgeInsets.all(10)padding: EdgeInsets.symmetric(horizontal:10, vertical:5)padding: EdgeInsets.only(left:10, top:5)child: 子组件 |
| SizedBox |
width: 100height: 50SizedBox (width:20) 水平间距SizedBox (height:10) 垂直间距child: 子组件 |
| SafeArea |
top: true / falsebottom: true / falseleft: true / falseright: true / falsechild: 子组件 |
| GridView |
GridView.count () 固定列数 crossAxisCount: 2 (列数)mainAxisSpacing: 10 (行间距)crossAxisSpacing: 10 (列间距)padding: EdgeInsets.all(10)childAspectRatio: 1 (宽高比)shrinkWrap: true / falsephysics: AlwaysScrollable / NeverScrollablechildren: 子组件列表**GridView.builder () 动态构建(高效)**crossAxisCount: 2 /gridDelegate 配置itemCount: 总数itemBuilder: 构建条目padding: EdgeInsets.all(10)mainAxisSpacing: 10crossAxisSpacing: 10 |