当前位置:网站首页>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(),
));
边栏推荐
- B站回应HR称用户是Loser:涉事面试官去年底已被劝退
- 解决错误:Optional int parameter ‘pageSize‘ is present but cannot be translated into a null value due to
- 高数---二重积分
- APT level comprehensive free kill with Shell
- Database auditing - an essential part of network security
- 思源笔记 本地存储无使用第三方同步盘,突然打不开文件。
- js基础知识整理之 —— 闭包
- js基础知识整理之 —— Math
- 用了这么多年的LinkedList,作者说自己从来不用它?为什么?
- Strict feedback nonlinear systems based on event trigger preset since the immunity of finite time tracking control
猜你喜欢
随机推荐
最新真实软件测试面试题分享,收藏了还怕进入不了大厂?
买母婴产品先来京东“券民空间站”抢券!大牌好物低至5折
No-code development platform form styling steps introductory course
3、Xendesktop更改发布桌面的显示名称(MCS静态桌面)
如何使用vlookup+excel数组公式 完成逆向查找?
智能电视竞争白热化,利用小程序共建生态突围
聚乙二醇衍生物4-Arm PEG-DSPE,四臂-聚乙二醇-磷脂
IDEA 重复代码的黄色波浪线取消设置
CIO修炼手册:成功晋升CIO的七个秘诀
为了面试阿里,熬夜肝完这份软件测试笔记后,Offer终于到手了
Nlog自定义时间
定了!8月起,网易将为本号粉丝提供数据分析培训,费用全免!
2022山东国际青少年眼睛健康产业展会,视力健康展,眼视光展
Speech Synthesis Model Cheat Sheet (1)
js基础知识整理之 —— 判断语句和三元运算符
Strict feedback nonlinear systems based on event trigger preset since the immunity of finite time tracking control
js基础知识整理之 —— 五种输出方式
4、Citrix MCS云桌面无法安装todesk等软件
mPEG-Cholesterol,mPEG-CLS,甲氧基-聚乙二醇-胆固醇可用于脂质体制备
如何突破测试/开发程序员思维?一种不一样的感觉......









