1. ListView(这个可能会经常用到):
scrollDirection: Axis.vertical, // horizontal, 滚动方向
reverse: true, // 所有条目从底部开始
physics: NeverScrollableScrollPhysics(),// 禁止滚动。固定住。
addAutomaticKeepAlives: false, // 进行垃圾回收
cacheExtent: 100.0, // 控制缓存??
ListView.builder() 用于生成一个特别长的列表,或者是创建动态列表
2.ListTile
ListTile(
leading: Icon(Icons.people),
trailing: Icon(Icons.mic),
title: Text("hello"),
subtitle: Text("haaaaaa "),
isThreeLine: true,
dense: true, // 更紧凑地排列
enabled: true, // 显示提示信息
selected: true, // 显示为蓝色
onTap: () {},
onLongPress: () {},
),
3. Icon
Icons.icon_name 所有的图标, 见: https://material.io/resources/icons/?style=baseline
color: Colors.pink, 参见所有的颜色
size: 40.0,
4. 其他的
4. FractionallySizedBox, 可以特制大小, 比如一个超大的按钮
widthFactor: 0.7, // 占据app整体的70% 的大小
heightFactor: 0.1,
5. 下面这几行: 如果有数据,就显示, 没有的话,就显示一个正在加载的按钮
return snapshot.hasData
? PhotoList(photos: snapshot.data)
: Center(child: CircularProgressIndicator());
6. AnimatedContainer,创建一个有渐变动画的容器
AnimatedContainer( //
width: _width,
height: _height,
decoration: BoxDecoration(
color: _color,
borderRadius: BorderRadius.circular(8),
),
duration: Duration(seconds: 1),
curve: Curves.fastOutSlowIn,
),
),
7. AnimatedOpacity, 淡入淡出效果
AnimatedOpacity(
opacity: _visible ? 1.0 : 0.0,
duration: Duration(milliseconds: 500),
child: Container(
width: 200.0,
height: 200.0,
color: Colors.pink
),
),
网友评论