hzy_normal_widget 0.0.6 hzy_normal_widget: ^0.0.6 copied to clipboard
适用与项目开发通用界面 配置.
文件目录 #
.
├── hzy_config.dart(配置文件 配置web 宽)
├── hzy_normal_getx_list_controller.dart(通用GetX 列表 Controller)
├── hzy_normal_getx_list_view.dart(通用GetX 列表 View)
├── hzy_normal_getx_view.dart(通用GetX View)
├── hzy_normal_less_widget.dart(通用 less widget)
├── hzy_normal_state_widget.dart(通用state widget)
├── hzy_normal_utils.dart (通用工具 适配web)
└── hzy_normal_widget.dart
使用的第三方 #
get: ^4.6.1
flutter_easyrefresh: ^2.2.1
ttcomment: ^0.0.1
导入 #
flutter #
dependencies:
hzy_normal_widget: ^latest_version
snapshot #
dependencies:
hzy_normal_widget:
git:
url: https://gitee.com/tengteng_fan/hzy_normal_widget.git
使用 #
import 'package:hzy_normal_widget/hzy_normal_widget.dart';
GetView GetViewList 使用事例 #
import 'package:flutter/material.dart';
import 'package:hzy_normal_widget/hzy_normal_widget.dart';
// ignore: use_key_in_widget_constructors
class TestV extends NormaGetxView<TestC> {
@override
Widget createBody(BuildContext context) {
return Container();
}
}
class TestC extends NormalGetxController {}
// ignore: use_key_in_widget_constructors
class ListV extends NormalGetxListView<ListC> {
/// 列表
@override
Widget createListView(BuildContext context) {
throw UnimplementedError();
}
/// 列表item
@override
Widget createListitem(BuildContext context, int index) {
throw UnimplementedError();
}
/// 列表占位页
@override
Widget? createEmptyWidget() {
throw UnimplementedError();
}
/// 创建失败 界面
@override
Widget? createErrorWidget() {
return null;
}
}
class ListC extends NormalGetxListController {}
NormalGetxController NormalGetxListController 详细介绍 #
abstract class NormalGetxController extends GetxController {
var pageState = PageState.initializedState.obs;
var sizew = 0.0.obs;
configsiezw(double maxw) {
sizew.value = maxw;
}
}
abstract class NormalGetxListController extends NormalGetxController
implements AbstractNetWork {
/// 刷新控制器
EasyRefreshController? refreshController;
int page = 1;
@override
void onInit() {
super.onInit();
refreshController = EasyRefreshController();
}
// 下啦刷新触发事件
configRefresh() async {
page = 1;
getnetworkdata(1, configNetWorkParmas());
}
// 上啦加载更多触发事件
configLoading() async {
page++;
getnetworkdata(2, configNetWorkParmas());
}
/// 网络请求 参数方法
@override
Map<String, dynamic>? configNetWorkParmas() {
return null;
}
/// 网络请求数据
@override
void getnetworkdata(int? type, Map<String, dynamic>? info) async {}
void endRefresh({int? type, PageState? state}) {
bool success = true;
bool noMore = false;
if (state == PageState.noMoreDataState) {
noMore = true;
}
/// 网络请求状态值
if (state == PageState.errorState ||
state == PageState.erroronlyTotal ||
state == PageState.errorshowRelesh) {
success = false;
}
if (refreshController != null) {
if (type == 1) {
refreshController!.finishRefresh(success: success);
refreshController!.resetLoadState();
} else if (type == 2) {
refreshController!.finishLoad(success: success, noMore: noMore);
}
}
pageState.value = state!;
}
}