fix:修复首页未加载的问题
This commit is contained in:
parent
33fd29d81d
commit
3e6868c395
@ -30,14 +30,7 @@ class LockMainLogic extends BaseGetXController {
|
|||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
loadMainDataLogic(entity.data!);
|
loadMainDataLogic(entity.data!);
|
||||||
Storage.saveMainListData(entity.data!);
|
Storage.saveMainListData(entity.data!);
|
||||||
// return entity.data!;
|
|
||||||
}
|
}
|
||||||
// else {
|
|
||||||
// // showToast("数据请求失败");
|
|
||||||
// // state.dataLength.value = 0;
|
|
||||||
// LockListInfoGroupEntity? lockListInfoGroupEntity = await Storage.getLockMainListData();
|
|
||||||
// loadMainDataLogic(lockListInfoGroupEntity!);
|
|
||||||
// }
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import 'package:get/get.dart';
|
|||||||
import 'package:star_lock/app_settings/app_colors.dart';
|
import 'package:star_lock/app_settings/app_colors.dart';
|
||||||
import 'package:star_lock/blue/blue_manage.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/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/noData.dart';
|
||||||
import 'package:star_lock/tools/submitBtn.dart';
|
import 'package:star_lock/tools/submitBtn.dart';
|
||||||
|
|
||||||
@ -33,24 +34,26 @@ class StarLockMainPage extends StatefulWidget {
|
|||||||
State<StarLockMainPage> createState() => _StarLockMainPageState();
|
State<StarLockMainPage> createState() => _StarLockMainPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget ,AutomaticKeepAliveClientMixin {
|
class _StarLockMainPageState extends State<StarLockMainPage>
|
||||||
final logic = Get.put(LockMainLogic());
|
with BaseWidget, AutomaticKeepAliveClientMixin {
|
||||||
final state = Get.find<LockMainLogic>().state;
|
final LockMainLogic logic = Get.put(LockMainLogic());
|
||||||
|
final LockMainState state = Get.find<LockMainLogic>().state;
|
||||||
|
|
||||||
Future<void> getHttpData(
|
Future<void> getHttpData(
|
||||||
{bool clearScanDevices = false, bool isUnShowLoading = false}) async {
|
{bool clearScanDevices = false, bool isUnShowLoading = false}) async {
|
||||||
LockListInfoGroupEntity? lockListInfoGroupEntity =
|
LockListInfoGroupEntity? lockListInfoGroupEntity =
|
||||||
await Storage.getLockMainListData();
|
await Storage.getLockMainListData();
|
||||||
if (lockListInfoGroupEntity != null) {
|
if (lockListInfoGroupEntity != null) {
|
||||||
var localLockListInfoGroupEntity = lockListInfoGroupEntity;
|
logic.loadMainDataLogic(lockListInfoGroupEntity);
|
||||||
logic.loadMainDataLogic(localLockListInfoGroupEntity);
|
}
|
||||||
|
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) {
|
if (clearScanDevices) {
|
||||||
BlueManage().scanDevices.clear();
|
BlueManage().scanDevices.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
});
|
});
|
||||||
@ -93,7 +96,7 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget ,Au
|
|||||||
haveBack: false,
|
haveBack: false,
|
||||||
haveOtherLeftWidget: true,
|
haveOtherLeftWidget: true,
|
||||||
leftWidget: Builder(
|
leftWidget: Builder(
|
||||||
builder: (context) => IconButton(
|
builder: (BuildContext context) => IconButton(
|
||||||
icon: Image.asset(
|
icon: Image.asset(
|
||||||
'images/main/mainLeft_menu_icon.png',
|
'images/main/mainLeft_menu_icon.png',
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
@ -125,23 +128,6 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget ,Au
|
|||||||
fit: BoxFit.cover,
|
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,
|
child: child,
|
||||||
));
|
));
|
||||||
return child;
|
return child;
|
||||||
@ -189,16 +175,16 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget ,Au
|
|||||||
|
|
||||||
Widget unHaveData() {
|
Widget unHaveData() {
|
||||||
return ListView(
|
return ListView(
|
||||||
children: [
|
children: <Widget>[
|
||||||
Column(
|
Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: <Widget>[
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 160.h,
|
height: 160.h,
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: <Widget>[
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 330.w,
|
width: 330.w,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
@ -255,7 +241,9 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget ,Au
|
|||||||
late StreamSubscription _teamEvent;
|
late StreamSubscription _teamEvent;
|
||||||
|
|
||||||
void _initLoadDataAction() {
|
void _initLoadDataAction() {
|
||||||
_teamEvent = eventBus.on<RefreshLockListInfoDataEvent>().listen((event) {
|
_teamEvent = eventBus
|
||||||
|
.on<RefreshLockListInfoDataEvent>()
|
||||||
|
.listen((RefreshLockListInfoDataEvent event) {
|
||||||
logic.pageNo = 1;
|
logic.pageNo = 1;
|
||||||
getHttpData(
|
getHttpData(
|
||||||
clearScanDevices: event.clearScanDevices,
|
clearScanDevices: event.clearScanDevices,
|
||||||
|
|||||||
@ -36,7 +36,6 @@ class _EasyRefreshToolState extends State<EasyRefreshTool> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
// TODO: implement initState
|
|
||||||
super.initState();
|
super.initState();
|
||||||
_controller = EasyRefreshController();
|
_controller = EasyRefreshController();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user