修复我的房屋页数组溢出问题

websocket关闭时修改provider状态
hmxc
张萌 3 years ago
parent 3718ba0130
commit 6bb4c899ea

@ -2,7 +2,6 @@
// Generated file. Do not edit.
//
// ignore_for_file: directives_ordering
// ignore_for_file: lines_longer_than_80_chars
import 'package:device_info_plus_web/device_info_plus_web.dart';

@ -181,10 +181,8 @@ class _SettingsPageState extends State<SettingsPage> {
CupertinoSwitch(
value: UserTool.appProveider.fireAlert,
onChanged: (value) {
UserTool.appProveider.setFireAlert(value);
if (UserTool.appProveider.fireAlert) {
if (value) {
WebSocketUtil().startWebSocket();
WebSocketUtil().setPrintHeart(value);
} else {
WebSocketUtil().closeWebSocket();
}

@ -0,0 +1,32 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ContactManagerPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
Paint paint = Paint()
..strokeWidth = 2.w
..style = PaintingStyle.stroke;
Path path = Path();
Rect rect = Rect.fromCircle(center: Offset(200.w, 200.w), radius: 120.w);
path.addArc(rect, 0, pi * 2);
Gradient gradient = LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Color(0xFFF9F9F9), Color(0xFF4AFD71)]);
paint.shader = gradient.createShader(rect);
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) {
return false;
}
@override
bool shouldRebuildSemantics(covariant CustomPainter oldDelegate) {
return false;
}
}

@ -60,6 +60,7 @@ class UserProvider extends ChangeNotifier {
HiveStore.appBox!.delete('token');
HiveStore.appBox!.delete('login');
WebSocketUtil().closeWebSocket();
notifyListeners();
}

@ -152,20 +152,21 @@ class HouseCard extends StatelessWidget {
],
).expand(),
//
!isOwner
isOwner
? SizedBox()
: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'到期时间${_isOverDate(DateUtil.getDateTime(model!.effectiveTimeEnd!)!)}',
'到期时间${_isOverDate(DateUtil.getDateTime(model!.effectiveTimeEnd ?? ''))}',
style:
Theme.of(context).textTheme.subtitle2!.copyWith(
color: Color(0xFF666666),
),
),
Text(
DateUtil.formatDateStr(model!.effectiveTimeEnd!,
DateUtil.formatDateStr(
model!.effectiveTimeEnd ?? '',
format: 'yyyy-MM-dd'),
style: Theme.of(context).textTheme.subtitle1,
),
@ -185,7 +186,10 @@ class HouseCard extends StatelessWidget {
);
}
String _isOverDate(DateTime date) {
String _isOverDate(DateTime? date) {
if (date == null) {
return '未知';
}
if (DateTime.now().isAfter(date)) {
return '已过期';
} else {

@ -2,6 +2,7 @@ import 'package:aku_community/base/base_style.dart';
import 'package:aku_community/ui/profile/house/identify_selection_page.dart';
import 'package:aku_community/ui/profile/house/my_house_list.dart';
import 'package:aku_community/ui/profile/house/tenant_house_list_page.dart';
import 'package:aku_community/ui/profile/house/upload_empty_form_page.dart';
import 'package:aku_community/widget/buttons/bottom_button.dart';
import 'package:aku_community/widget/others/user_tool.dart';
import 'package:bot_toast/bot_toast.dart';
@ -54,7 +55,6 @@ class _HouseOwnersPageState extends State<HouseOwnersPage> {
}
bool get isOwner {
switch (UserTool.userProvider.userDetailModel!.type) {
case 1:
return true;
@ -91,16 +91,19 @@ class _HouseOwnersPageState extends State<HouseOwnersPage> {
@override
void initState() {
Function cancel = BotToast.showLoading();
try {
Future.delayed(Duration(milliseconds: 300), () async {
Future.delayed(Duration(milliseconds: 300), () async {
Function cancel = BotToast.showLoading();
try {
await UserTool.userProvider.updateUserDetail();
});
} catch (e) {
LoggerData.addData(e);
}
_onload = false;
cancel();
UserTool.appProveider.updateHouses(await HouseFunc.passedHouses);
} catch (e) {
LoggerData.addData(e);
}
_onload = false;
cancel();
setState(() {});
});
super.initState();
}
@ -128,7 +131,7 @@ class _HouseOwnersPageState extends State<HouseOwnersPage> {
: EasyRefresh(
header: MaterialHeader(),
controller: _refreshController,
firstRefresh: true,
firstRefresh: false,
onRefresh: () async {
appProvider.updateHouses(await HouseFunc.passedHouses);
},
@ -170,7 +173,7 @@ class _HouseOwnersPageState extends State<HouseOwnersPage> {
child: Text('添加房屋'),
),
),
if (!isOwner && !_emptyHouse) _contractRelevant(),
if (!isOwner && !_emptyHouse) _contractRelevant().expand()
],
),
),
@ -186,7 +189,7 @@ class _HouseOwnersPageState extends State<HouseOwnersPage> {
if (result == true) _refreshController.callRefresh();
}
//
///
Widget _contractRelevant() {
return GridView.count(
crossAxisCount: 2,
@ -197,7 +200,9 @@ class _HouseOwnersPageState extends State<HouseOwnersPage> {
_cardBuild(R.ASSETS_ICONS_PAY_PNG, '缴费查询', '查看租金及保证金情况', () {}),
_cardBuild(R.ASSETS_ICONS_CHANGE_PNG, '合同变更', '变更合同信息、重新签约', () {}),
_cardBuild(R.ASSETS_ICONS_CONTRACT_PNG, '合同续签', '到期前线上办理续签手续', () {}),
_cardBuild(R.ASSETS_ICONS_FINISH_PNG, '合同终止', '线上申请终止合同', () {})
_cardBuild(R.ASSETS_ICONS_FINISH_PNG, '合同终止', '线上申请终止合同', () {
Get.to(() => UploadEmptyFormPage());
})
],
);
}

@ -1,4 +1,5 @@
import 'dart:async';
import 'package:aku_community/widget/others/user_tool.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:power_logger/power_logger.dart';
import 'package:web_socket_channel/io.dart';
@ -102,6 +103,8 @@ class WebSocketUtil {
onError?.call(e);
LoggerData.addData(e);
}
WebSocketUtil().setPrintHeart(true);
}
//
@ -176,6 +179,7 @@ class WebSocketUtil {
}
endReconnect();
destoryHeart();
UserTool.appProveider.setFireAlert(false);
_socketStatus = SOCKETSTATUS.CLOSED;
}

@ -77,7 +77,7 @@ packages:
name: async
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.7.0"
version: "2.5.0"
auto_size_text:
dependency: transitive
description:
@ -182,7 +182,7 @@ packages:
name: charcode
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.1"
version: "1.2.0"
checked_yaml:
dependency: transitive
description:
@ -682,7 +682,7 @@ packages:
name: meta
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.4.0"
version: "1.3.0"
mime:
dependency: transitive
description:
@ -1046,7 +1046,7 @@ packages:
name: source_span
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.1"
version: "1.8.0"
sp_util:
dependency: transitive
description:
@ -1123,7 +1123,7 @@ packages:
name: test_api
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.4.1"
version: "0.2.19"
timing:
dependency: transitive
description:

Loading…
Cancel
Save