diff --git a/lib/blue/sender_beforeDataManage.dart b/lib/blue/sender_beforeDataManage.dart index 09d83cca..14f59aeb 100755 --- a/lib/blue/sender_beforeDataManage.dart +++ b/lib/blue/sender_beforeDataManage.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:flutter/cupertino.dart'; import 'package:star_lock/blue/entity/lock_user_no_list_entity.dart'; import 'package:star_lock/blue/io_protocol/io_cleanUpUsers.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; @@ -276,6 +277,12 @@ class SenderBeforeDataManage { // 普通用户接收电子钥匙之后 更新锁用户NO Future _updateLockUserNo(List dataList) async { + // 使用空值感知操作符安全访问 keyId + final String? keyId = CommonDataManage().currentKeyInfo.keyId?.toString(); + if (keyId == null) { + debugPrint('keyId获取失败'); + return; + } final LockNetTokenEntity entity = await ApiRepository.to.updateLockUserNo( keyId: CommonDataManage().currentKeyInfo.keyId.toString(), lockUserNo: CommonDataManage().currentKeyInfo.lockUserNo.toString()); if (entity.errorCode!.codeIsSuccessful) {