当前位置:网站首页>flutter 每个要注意的点
flutter 每个要注意的点
2022-08-02 23:19:00 【氤氲息】
列表
1.数据为空时的提示语
return MaterialApp(
color: Colors.transparent,
home: widget.upList.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()//如果有数据就返回这个里面的内容
2.要判断列表数据是否为空
child: MediaQuery.removePadding(
removeTop: true,
context: context,
child: widget.upList.isEmpty//如果数据为空就显示Container(),如果有内容就显示列表数据
? Container()
: ListView.builder(
shrinkWrap: true,
itemCount: widget.upList.length,
itemBuilder: (BuildContext context, int index) {
BottleModel upList = widget.upList[index];
return GestureDetector(
onTap: () {
if (widget.onItemClicked != null) {
widget.onItemClicked!(index);
//延时
Future.delayed(const Duration(milliseconds: 500), () {
EventBusUtil.fire(
OnCloseBottleRefresh(CloudCustomDataBean.TYPE_DRIFT_BOTTLE));
});
}
},
child: Stack(
alignment: Alignment.topRight,
children: [
if (index % 3 == 2)
Container(
width: width,
margin: const EdgeInsets.only(
top: 16, left: 16, right: 16),
padding: const EdgeInsets.only(
left: 16, top: 16, bottom: 8, right: 16),
decoration: BoxDecoration(
color: const Color(0xFFFBFFF2),
borderRadius: BorderRadius.circular(12),
boxShadow: const [
BoxShadow(
color: Color(0xFFDBEBB6),
blurRadius: 1,
),
],
),
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
upList.text!,
style: const TextStyle(
color: Color(0xFF333333),
fontSize: 18),
),
Container(
margin: const EdgeInsets.only(top: 8),
child: Text(
DateUtil.formatDateMs(
upList.downTime! * 1000,
format: 'yyyy.MM.dd'),
style: const TextStyle(
color: Color(0xFF999999),
fontSize: 12),
),
)
],
),
),
Positioned(
top: 7,
right: 15,
child: showMessageNumView(upList.noReadNum),
)
],
),
);
})),
3.下拉分页加载
final ScrollController _scrollController = ScrollController();
bool _hasMore = true;
bool _isLoad = false;
int pageSize =20;
@override
void initState() {
super.initState();
// 监听滚动事件
_scrollController.addListener(() {
if (_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent) {
//达到最大滚动位置
_isLoad = true;
if (_hasMore && _isLoad) {
DownList? downList = currentMessageList?.last;
_getReplyList(
driftBottleId: downList?.driftBottleId,
pageTime: downList?.createTime,
status: 1,);
}
}
});
WidgetsBinding.instance!.addPostFrameCallback(_afterLayout);
}
SingleChildScrollView(
controller: _scrollController,
reverse: currentMessageList!.length >= 6
? true
: cloumHeight >= Global.screenHeight - 100, //注意设置为反向
padding: const EdgeInsets.fromLTRB(12, 0, 12, 0),
child: Column(
key: _containerKey,
children:
(currentMessageList == null || currentMessageList.length == 0)
? [Container()]: replyList == null
? [Container()]
: currentMessageList.map((e) => MsgContainer(replyList: replyList!,downList: e,)).toList(),
));
边栏推荐
- RollBack Rx Professional RMC 安装教程
- D with json
- Jmeter secondary development to realize rsa encryption
- 买母婴产品先来京东“券民空间站”抢券!大牌好物低至5折
- What is the matter that programmers often say "the left hand is knuckled and the right hand is hot"?
- mPEG-Cholesterol,mPEG-CLS,甲氧基-聚乙二醇-胆固醇可用于脂质体制备
- 2022第十一届财经峰会:优炫软件斩获双项大奖
- 数据库审计 - 网络安全的重要组成部分
- No code development platform data ID introductory tutorial
- KubeSphere监控失效为NAN的问题
猜你喜欢
程序员常说的“左手锟斤拷,右手烫烫烫”是怎么回事?
用大白话解释“什么是ERP?” 看完这篇就全明白了
Jmeter二次开发实现rsa加密
2022第十一届财经峰会:优炫软件斩获双项大奖
HCIP(17)
精心整理16条MySQL使用规范,减少80%问题,推荐分享给团队
RollBack Rx Professional RMC 安装教程
Swift中的类型相关内容
B站回应HR称用户是Loser:涉事面试官去年底已被劝退
解决错误:Optional int parameter ‘pageSize‘ is present but cannot be translated into a null value due to
随机推荐
Technology Sharing | How to do assertion verification for xml format in interface automation testing?
WebShell 木马免杀过WAF
The latest real software test interview questions are shared. Are you afraid that you will not be able to enter the big factory after collecting them?
d实验新异常
redis的学习笔记
程序员的七夕浪漫时刻
@GetMapping、@PostMapping、@PutMapping、@DeleteMapping的区别
B站回应HR称用户是Loser:涉事面试官去年底已被劝退
Week 7 CNN Architectures - LeNet-5、AlexNet、VGGNet、GoogLeNet、ResNet
js基础知识整理之 —— 变量和数据类型
4、Citrix MCS云桌面无法安装todesk等软件
脂溶性胆固醇-聚乙二醇-叠氮,Cholesterol-PEG-Azide,CLS-PEG-N3
Speech Synthesis Model Cheat Sheet (1)
DownMusic总结记录
秒懂网络拓扑中的下一跳地址
Controller层代码这么写,简洁又优雅!
微信小程序实现lot开发09 接入微信登录
vant-swipe adaptive picture height + picture preview
HCIP(17)
一文读懂 Web 3.0 应用架构