app-starlock/star_lock/lib/tools/EasyRefreshTool.dart
魏少阳 87e61960c3 1、修复锁详情横向刷新问题
2、锁详情添加锁状态(待生效、正常使用、已过期等状态)
3、修复所有安卓机型,左滑删除字体不显示问题
4、修复登录、注册、忘记密码等模块切换密码框需二次点击功能
2024-03-19 18:04:51 +08:00

66 lines
1.4 KiB
Dart

import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/cupertino.dart';
/*
* 下拉刷新封装
*
*
*
* child 显示组件
* onRefresh 上拉刷新
* onLoad 下拉刷新
* isMore 是否存在分页
* page 页数
*
* */
GlobalKey<_EasyRefreshToolState> childKey = GlobalKey();
class EasyRefreshTool extends StatefulWidget {
Widget child;
Function? onRefresh;
Function? onLoad;
late int isMore;
late int page;
EasyRefreshTool({Key? key,required this.child,this.onRefresh,this.onLoad,this.isMore=0,this.page=0}) : super(key: key);
@override
State<EasyRefreshTool> createState() => _EasyRefreshToolState();
}
class _EasyRefreshToolState extends State<EasyRefreshTool> {
late EasyRefreshController _controller;
@override
void initState() {
// TODO: implement initState
super.initState();
_controller = EasyRefreshController();
}
@override
Widget build(BuildContext context) {
return EasyRefresh(
controller: _controller,
header: const MaterialHeader(),
footer: const MaterialFooter(),
triggerAxis: Axis.vertical,
onRefresh: widget.onRefresh!=null?() async {
if(widget.onRefresh != null){
widget.onRefresh!();
}
}:null,
onLoad: widget.onLoad!=null?() async {
// if(widget.isMore>0){
widget.onLoad!();
// }
}:null,
child: widget.child,
);
}
}