使用了flutter一段时间,愈来愈喜欢flutter了,flutter比咱们想象中的强大。这篇文章介绍了怎么使用flutter来展现一个很漂亮的list,先看下效果图。git
样式仍是很漂亮的,下面咱们一步一步完成这个小项目。github
assets:
- assets/images/
复制代码
colors # 颜色
data # list的数据
# ...
复制代码
Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
title: Text(
'flutter awesome list',
style: TextStyle(
color: Colors.white,
),
),
),
body: HomeBody(),
);
复制代码
class MyClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
Path p = Path();
p.lineTo(size.width, 0.0);
p.lineTo(size.width, size.height / 4.75);
p.lineTo(0.0, size.height / 3.75);
p.close();
return p;
}
@override
bool shouldReclip(CustomClipper oldClipper) {
return true;
}
}
复制代码
ListTile(
leading: CircleAvatar(
backgroundImage: NetworkImage(CONSTANT.userAvatar),
),
title: Text(
CONSTANT.userName,
style: CONSTANT.defaultTextStyle,
textScaleFactor: 1.5,
),
subtitle: Text(
CONSTANT.userProfile,
style: CONSTANT.defaultTextStyle,
),
)
复制代码
Hero(
tag: index,
child: FadeInImage(
image: NetworkImage(data.image),
fit: BoxFit.cover,
placeholder: AssetImage('assets/images/loading.gif'),
),
)
复制代码
最后就是详情页面的展现,这个页面并无写什么样式,展现了从列表页跳转过来时,图片的过渡效果,有兴趣的同窗能够丰富下页面的样式和内容canvas