flutter_chen_common

Last updated:

0 purchases

flutter_chen_common Image
flutter_chen_common Images
Add to Cart

Description:

flutter chen common

简介 #
Flutter common package内涵一些开发常用的组件跟工具类以及功能模块等等,代码简洁优雅且可高度定制
文档链接🔗
dependencies:
flutter_chen_common: 最新版本
copied to clipboard

Utils #

SpUtil:SharedPreferences工具类,温馨提示需要init.
FunctionUtil:为所以方法扩展实现节流防抖.
LogUtil : 优雅日志打印.
DateUtil : 日期转换格式化输出.
TextUtil : 银行卡号每隔4位加空格,每隔3三位加逗号,隐藏手机号等等.
EncryptUtil : 异或对称加/解密,md5加密,Base64加/解密.
JsonUtil : json转换工具类.


Helper #

CommonHelper:通用的各类弹窗、提示.
ImageHelper:图片选择、裁剪、上传.
OssHelper : oss上传,需传一个请求oss配置方法.
UpdateHelper : 自定义版本更新.
PermissionHelper : 权限判断申请.
CacheHelper : 应用缓存.


Widgets #

RefreshWidget:包含上拉加载、下拉刷新、回至顶部、页面数据状态视图(加载、空数据、列表、瀑布流)等功能的列表刷新组件.
ComUpload:图片上传选择器.
ComAlbum:仿微信朋友圈图片展示.
ComGallery:滑动切换放缩旋转的图片预览.
ComSwiper:支持多形式轮播图.
ComImage:网络缓存预加载淡入淡出图片
ComTab:可实现所有场景Tab.
ComButton:通用可渐变按钮、统一节流.
ComSearch:通用搜索框.
ComTextField:通用文本框.
ComRadio:勾选样式Radio.
BaseWidget:多状态布局,无网络自动切换该状态布局.


网络请求 #
/// 初始化RequestClient,传请求url以及请求拦截器
await RequestClient.init(
baseUrl: Env.getEnvConfig().baseUrl,
interceptors: [RequestInterceptor()]);

/// 使用
RequestClient.instance.request(
"/xxxx",
method: HttpType.post.name,
)
copied to clipboard

配置主题以及OSS #
/// 初始化SharedPreferences
await SpUtil.init();
ComConfig.config(theme: AppColors.theme);
ComConfig.setOssConfig(Global.ossConfig);

static Future<Map<String, dynamic>> ossConfig() async {
var res = await AppApi.ossToken();
var params = {
"accessKeyId": res["accessKeyId"],
"policy": res["policy"],
"signature": res["signature"],
"url": "https://${res["bucket"]}.oss-ap-southeast-1.aliyuncs.com",
"dir": "appName"
};
return params;
}
copied to clipboard

RefreshWidget #
class DemoLogic extends PagingController {
@override
Future<PagingResponse> loadData() async {
// TODO: implement loadData
dynamic result = {"current": 1, "total": 3, "records": []};
await Future.delayed(2000.milliseconds, () {
for (var i = 0; i < 20; ++i) {
result["records"]?.add(i);
}
});

return PagingResponse.fromMapJson(result);
}
}

class DemoPage extends StatelessWidget {
DemoPage({Key? key}) : super(key: key);

final logic = Get.find<DemoLogic>();

@override
Widget build(BuildContext context) {
return GetBuilder<DemoLogic>(
builder: (controller) {
return Scaffold(
body: RefreshWidget(
controller: logic,
slivers: [
RefreshListWidget(
itemBuilder: (item, index) => _buildItem(index),
controller: logic,
showList: false),
],
));
},
id: logic.pagingState.refreshId,
);
}

Widget _buildItem(index) {
if (index % 3 == 0) {
return Container(
color: Colors.deepOrange,
width: double.infinity,
height: 300.h,
);
}
return Container(
color: Colors.green,
width: double.infinity,
height: 200.h,
);
}
}
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.