当前位置:网站首页>flutter 制作嵌套列表
flutter 制作嵌套列表
2022-08-10 02:37:00 【氤氲息】
总列,滑动,嵌套列,列表
@override
Widget build(BuildContext context) {
return Column(//首先是一列
children: [
//如果想让一部分不滑动,可以在这里写
Expanded(//填充
child: SingleChildScrollView(//可滑动列表
child: Column(//可滑动列表里面放一个列
children: [
//这里可继续添加container,因在滑动列表里面,是可以滑动的
Container(
child: MediaQuery.removePadding(//最后就是列表了
removeTop: true,
context: context,
child: ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: 10,
itemBuilder: (BuildContext context, int index) {
return Container(
child: Text(""),
);
})),
)
],
),
))
],
);
}
添加缺省页
@override
Widget build(BuildContext context) {
return MaterialApp(
color: Colors.transparent,
home://缺省页
richRankList == null ||
richRankList!.rankList == null ||
richRankList!.rankList!.isEmpty
? Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
alignment: Alignment.center,
child: Container(
margin: const EdgeInsets.only(bottom: 120),
child: Column(children: [
ContentText(S.current.bottle_no_data, 14.0,
CommonColors.getTextWeakColor()),
TopPadding(30),
])),
)
],
)
: Scaffold(
backgroundColor: Colors.transparent,
body: Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
if (getSex(0) != 0 ||
getBirthday(0) != -1 ||
getRank(0) != -1)
topThree(),
Container(
color: Colors.transparent,
padding: const EdgeInsets.only(bottom: 20),
child: MediaQuery.removePadding(
removeTop: true,
context: context,
child: richRankList == null ||
richRankList!.rankList == null ||
richRankList!.rankList!.isEmpty
? Container()
: ListView.builder(
shrinkWrap: true,
physics:
const NeverScrollableScrollPhysics(),
itemCount:
richRankList!.rankList!.length,
itemBuilder: (BuildContext context,
int index) {
RichRankList rankList =
richRankList!
.rankList![index];
return GestureDetector(
child: Offstage(
offstage: index == 1 ||
index == 1 ||
index == 2,
child: Container(
width: width,
margin:
const EdgeInsets.only(
top: 16,
left: 16,
right: 16),
padding:
const EdgeInsets.only(
left: 16,
top: 8,
bottom: 8,
right: 16),
decoration: BoxDecoration(
color: const Color(
0xFFFBFFF2),
borderRadius:
BorderRadius
.circular(12),
boxShadow: const [
BoxShadow(
color: Color(
0xFFDBEBB6),
blurRadius: 1,
),
],
),
child: Row(
children: [
Container(
child: Text(
"${rankList.rank ?? 0}",
style: const TextStyle(
color: Colors
.black,
fontSize: 16),
),
),
Row(
children: [
Container(
margin: const EdgeInsets
.only(
top: 10,
left: 32),
height: 58,
width: 58,
child:
ClipRRect(
borderRadius:
BorderRadius.circular(
50),
child: ImageUtile
.imageWidget(
rankList.avatar ??
Global
.defUserImag,
),
)),
Container(
margin:
const EdgeInsets
.only(
top: 10,
left:
8),
child: Column(
crossAxisAlignment:
CrossAxisAlignment
.start,
children: [
LimitedBox(
maxWidth:
130,
child:
Text(
rankList.nickname ??
"",
maxLines:
1,
overflow:
TextOverflow.ellipsis,
style:
const TextStyle(
fontSize:
16,
color:
Color(0xFF040404),
decoration:
TextDecoration.none,
),
),
),
Container(
alignment:
Alignment
.centerLeft,
margin: const EdgeInsets
.only(
top:
7.0),
child:
Row(
children: [
Container(
child:
SizedBox(
width: 20,
height: 20,
child: ImageUtile.imageWidget("assets/images/[email protected]"),
),
),
Container(
alignment: Alignment.center,
margin: const EdgeInsets.only(right: 6),
padding: const EdgeInsets.fromLTRB(3, 2, 5, 2),
child: Row(mainAxisSize: MainAxisSize.min, children: [
Image(image: AssetImage(rankList.sex == 1 ? 'assets/images/icon_gender_male.png' : 'assets/images/icon_gender_female.png'), gaplessPlayback: true, width: 11, height: 11),
Padding(
padding: const EdgeInsets.only(top: 1),
child: Text(
// '${UserInfoUtil().getAge(widget.birthday!)}',
'${rankList.age ?? 0}',
style: const TextStyle(
fontSize: 9.0,
color: Colors.white,
),
),
)
]),
decoration: BoxDecorationUtil().setFillBoxDecoration(rankList.sex == 1 ? CommonColors.getColor7E8FF7 : CommonColors.getColorF77EBE, 10.0)),
SizedBox(
width:
20,
height:
20,
child:
ImageUtile.imageWidget("assets/images/[email protected]"),
),
],
),
),
],
),
),
],
),
const Spacer(),
Container(
alignment: Alignment
.center,
margin:
const EdgeInsets
.only(
top: 7.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment
.center,
children: [
SizedBox(
width: 20,
height: 20,
child: ImageUtile
.imageWidget(
"assets/images/[email protected]"),
),
Container(
alignment:
Alignment
.center,
margin: const EdgeInsets
.only(
right: 6),
padding:
const EdgeInsets
.fromLTRB(
3,
2,
5,
2),
child: Text(
"${rankList.richValue ?? 0}",
style: const TextStyle(
fontSize:
12),
),
),
],
),
),
],
)),
),
);
})),
)
],
),
),
),
],
)),
);
}
边栏推荐
- MySQL:你做过哪些MySQL的优化?
- How to write a high-quality test case?
- HACKTHEBOX——Bank
- 【8.8】代码源 - 【不降子数组游戏】【最长上升子序列计数(Bonus)】【子串(数据加强版)】
- (十四)时间延时任务及定时任务
- 【红队】ATT&CK - 自启动 - 利用LSA身份验证包自启动机制
- Robust Real-time LiDAR-inertial Initialization (Real-time Robust LiDAR Inertial Initialization) Paper Learning
- Completion of the flag set in 2022
- Research on IC enterprises
- nodejs 时钟案例(fs模块),重复使用fs.writeFile方法,旧内容会被覆盖
猜你喜欢
[Kali Security Penetration Testing Practice Course] Chapter 9 Wireless Network Penetration
liunx PS1 settings
Meteor accelerator Trojan analysis and disposal plan
[Kali Security Penetration Testing Practice Course] Chapter 7 Privilege Escalation
Pagoda server PHP+mysql web page URL jump problem
ArcGIS Advanced (1) - Install ArcGIS Enterprise and create an sde library
Little rookie Hebei Unicom induction training essay
【语义分割】2022-HRViT CVPR
storage of data in memory
MySQL: What MySQL optimizations have you done?
随机推荐
【8.8】代码源 - 【不降子数组游戏】【最长上升子序列计数(Bonus)】【子串(数据加强版)】
P1564 Worship
单体架构应用和分布式架构应用的区别
论旅行之收获
Pagoda server PHP+mysql web page URL jump problem
2022.8.9 Exam Travel Summary
2020.11.22 Exam Goldbach Conjecture Solution
【Image Classification】2022-ConvMixer ICLR
nodejs 时钟案例(fs模块),重复使用fs.writeFile方法,旧内容会被覆盖
兴业数金一面
[Kali Security Penetration Testing Practice Course] Chapter 9 Wireless Network Penetration
liunx PS1 设置
浅写一个下拉刷新组件
yolov5+usb相机
关于redis在业务中的应用问题,如何解决?
what is a microcontroller or mcu
【二叉树-中等】508. 出现次数最多的子树元素和
【语义分割】2022-HRViT CVPR
实例044:矩阵相加
[Red Team] ATT&CK - Auto Start - Registry Run Key, Startup Folder