简介
Flutter common package内涵一些开发常用的组件跟工具类以及功能模块等等
dependencies:
flutter_chen_common: 最新版本
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.
网络请求
/// 初始化RequestClient,传请求url以及请求拦截器
await RequestClient.init(
baseUrl: Env.getEnvConfig().baseUrl,
interceptors: [RequestInterceptor()]);
/// 使用
RequestClient.instance.request(
"/xxxx",
method: HttpType.post.name,
)
配置主题以及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;
}
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,
);
}
}
Libraries
- common/helper/common_helper
- common/helper/helper
- common/helper/image_helper
- common/helper/oss_helper
- common/helper/permission_helper
- common/helper/update_helper
- common/style
- common/utils/cache_util
- common/utils/date_util
- common/utils/encrypt_util
- common/utils/function_util
- common/utils/json_util
- common/utils/log_util
- common/utils/sp_util
- common/utils/text_util
- common/utils/utils
- config/com_config
- flutter_chen_common
- request/request
- request/request_handle
- request/request_response
- widgets/base/com_album
- widgets/base/com_arrow
- widgets/base/com_container
- widgets/base/com_empty
- widgets/base/com_gallery
- widgets/base/com_image
- widgets/base/com_loading
- widgets/base/com_radio
- widgets/base/com_search
- widgets/base/com_swiper
- widgets/base/com_tabbar
- widgets/base/com_textfield
- widgets/base/com_upload
- widgets/refresh/back_top_widget
- widgets/refresh/refresh_controller
- widgets/refresh/refresh_state
- widgets/refresh/refresh_widget
- widgets/widgets