fix:修复首页未加载的问题
This commit is contained in:
parent
33fd29d81d
commit
3e6868c395
@ -30,14 +30,7 @@ class LockMainLogic extends BaseGetXController {
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
loadMainDataLogic(entity.data!);
|
||||
Storage.saveMainListData(entity.data!);
|
||||
// return entity.data!;
|
||||
}
|
||||
// else {
|
||||
// // showToast("数据请求失败");
|
||||
// // state.dataLength.value = 0;
|
||||
// LockListInfoGroupEntity? lockListInfoGroupEntity = await Storage.getLockMainListData();
|
||||
// loadMainDataLogic(lockListInfoGroupEntity!);
|
||||
// }
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ import 'package:get/get.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/blue/blue_manage.dart';
|
||||
import 'package:star_lock/main/lockMian/lockList/lockList_xhj_page.dart';
|
||||
import 'package:star_lock/main/lockMian/lockMain/lockMain_state.dart';
|
||||
import 'package:star_lock/tools/noData.dart';
|
||||
import 'package:star_lock/tools/submitBtn.dart';
|
||||
|
||||
@ -33,24 +34,26 @@ class StarLockMainPage extends StatefulWidget {
|
||||
State<StarLockMainPage> createState() => _StarLockMainPageState();
|
||||
}
|
||||
|
||||
class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget ,AutomaticKeepAliveClientMixin {
|
||||
final logic = Get.put(LockMainLogic());
|
||||
final state = Get.find<LockMainLogic>().state;
|
||||
class _StarLockMainPageState extends State<StarLockMainPage>
|
||||
with BaseWidget, AutomaticKeepAliveClientMixin {
|
||||
final LockMainLogic logic = Get.put(LockMainLogic());
|
||||
final LockMainState state = Get.find<LockMainLogic>().state;
|
||||
|
||||
Future<void> getHttpData(
|
||||
{bool clearScanDevices = false, bool isUnShowLoading = false}) async {
|
||||
LockListInfoGroupEntity? lockListInfoGroupEntity =
|
||||
await Storage.getLockMainListData();
|
||||
if (lockListInfoGroupEntity != null) {
|
||||
var localLockListInfoGroupEntity = lockListInfoGroupEntity;
|
||||
logic.loadMainDataLogic(localLockListInfoGroupEntity);
|
||||
logic.loadMainDataLogic(lockListInfoGroupEntity);
|
||||
}
|
||||
lockListInfoGroupEntity =
|
||||
(await logic.getStarLockInfo(isUnShowLoading: isUnShowLoading)).data;
|
||||
if (lockListInfoGroupEntity != null) {
|
||||
logic.loadMainDataLogic(lockListInfoGroupEntity);
|
||||
}
|
||||
await logic.getStarLockInfo(isUnShowLoading: isUnShowLoading);
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
if (clearScanDevices) {
|
||||
BlueManage().scanDevices.clear();
|
||||
}
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
setState(() {});
|
||||
});
|
||||
@ -93,7 +96,7 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget ,Au
|
||||
haveBack: false,
|
||||
haveOtherLeftWidget: true,
|
||||
leftWidget: Builder(
|
||||
builder: (context) => IconButton(
|
||||
builder: (BuildContext context) => IconButton(
|
||||
icon: Image.asset(
|
||||
'images/main/mainLeft_menu_icon.png',
|
||||
color: Colors.white,
|
||||
@ -125,23 +128,6 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget ,Au
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
// decoration: BoxDecoration(
|
||||
// // 设置渐变
|
||||
// gradient: LinearGradient(
|
||||
// // 渐变颜色列表
|
||||
// colors: [
|
||||
// AppColors.mainColor.withOpacity(0.8), // 左上角颜色
|
||||
// AppColors.mainColor.withOpacity(0.4), // 右上角颜色
|
||||
// Colors.white, // 右下角颜色
|
||||
// Colors.white, // 左下角颜色
|
||||
// ],
|
||||
// // 渐变的起始和结束位置
|
||||
// begin: Alignment.topLeft,
|
||||
// end: Alignment.bottomRight,
|
||||
// // 颜色停靠点,对应颜色数组的索引位置
|
||||
// stops: [0.0, 0.23, 0.47, 1],
|
||||
// ),
|
||||
// ),
|
||||
child: child,
|
||||
));
|
||||
return child;
|
||||
@ -189,16 +175,16 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget ,Au
|
||||
|
||||
Widget unHaveData() {
|
||||
return ListView(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
height: 160.h,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: 330.w,
|
||||
child: InkWell(
|
||||
@ -255,7 +241,9 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget ,Au
|
||||
late StreamSubscription _teamEvent;
|
||||
|
||||
void _initLoadDataAction() {
|
||||
_teamEvent = eventBus.on<RefreshLockListInfoDataEvent>().listen((event) {
|
||||
_teamEvent = eventBus
|
||||
.on<RefreshLockListInfoDataEvent>()
|
||||
.listen((RefreshLockListInfoDataEvent event) {
|
||||
logic.pageNo = 1;
|
||||
getHttpData(
|
||||
clearScanDevices: event.clearScanDevices,
|
||||
|
||||
@ -36,7 +36,6 @@ class _EasyRefreshToolState extends State<EasyRefreshTool> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
_controller = EasyRefreshController();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user