fix:修复首页未加载的问题

This commit is contained in:
anfe 2024-06-07 11:39:08 +08:00
parent 33fd29d81d
commit 3e6868c395
4 changed files with 18 additions and 38 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -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;
}

View File

@ -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,

View File

@ -36,7 +36,6 @@ class _EasyRefreshToolState extends State<EasyRefreshTool> {
@override
void initState() {
// TODO: implement initState
super.initState();
_controller = EasyRefreshController();
}