diff --git a/lib/pages/common/multi_select_controller.dart b/lib/pages/common/multi_select_controller.dart index 6f7dd1e6..37e2325f 100644 --- a/lib/pages/common/multi_select_controller.dart +++ b/lib/pages/common/multi_select_controller.dart @@ -18,11 +18,13 @@ abstract class MultiSelectController extends CommonController { } void handleSelect([bool checked = false]) { - List? list = (loadingState.value as Success?)?.response; - if (list.isNullOrEmpty.not) { - loadingState.value = LoadingState.success( - list!.map((item) => item..checked = checked).toList()); - checkedCount.value = checked ? list.length : 0; + if (loadingState.value is Success) { + List list = (loadingState.value as Success).response; + if (list.isNotEmpty) { + loadingState.value = LoadingState.success( + list.map((item) => item..checked = checked).toList()); + checkedCount.value = checked ? list.length : 0; + } } if (checked.not) { enableMultiSelect.value = false; diff --git a/lib/pages/common/reply_controller.dart b/lib/pages/common/reply_controller.dart index 32c89b38..9882061f 100644 --- a/lib/pages/common/reply_controller.dart +++ b/lib/pages/common/reply_controller.dart @@ -200,8 +200,9 @@ abstract class ReplyController extends CommonController { savedReplies[key] = null; if (GlobalData().grpcReply) { ReplyInfo replyInfo = Utils.replyCast(res); - MainListReply response = - (loadingState.value as Success?)?.response ?? MainListReply(); + MainListReply response = loadingState.value is Success + ? (loadingState.value as Success).response + : MainListReply(); if (oid != null) { response.replies.insert(hasUpTop ? 1 : 0, replyInfo); } else { @@ -210,8 +211,9 @@ abstract class ReplyController extends CommonController { count.value += 1; loadingState.value = LoadingState.success(response); } else { - ReplyData response = - (loadingState.value as Success?)?.response ?? ReplyData(); + ReplyData response = loadingState.value is Success + ? (loadingState.value as Success).response + : ReplyData(); response.replies ??= []; if (oid != null) { response.replies diff --git a/lib/pages/history/controller.dart b/lib/pages/history/controller.dart index d5ea540e..c86c8aba 100644 --- a/lib/pages/history/controller.dart +++ b/lib/pages/history/controller.dart @@ -179,9 +179,11 @@ class HistoryController extends MultiSelectController { TextButton( onPressed: () async { Get.back(); - _onDelete(((loadingState.value as Success).response as List) - .where((e) => e.checked) - .toList()); + if (loadingState.value is Success) { + _onDelete(((loadingState.value as Success).response as List) + .where((e) => e.checked) + .toList()); + } }, child: const Text('确认'), ) diff --git a/lib/pages/video/detail/reply_reply/view.dart b/lib/pages/video/detail/reply_reply/view.dart index edf7b860..d0bc05b7 100644 --- a/lib/pages/video/detail/reply_reply/view.dart +++ b/lib/pages/video/detail/reply_reply/view.dart @@ -298,19 +298,19 @@ class _VideoReplyReplyPanelState extends State { _savedReplies[key] = null; if (GlobalData().grpcReply) { ReplyInfo replyInfo = Utils.replyCast(res); - List list = - (_videoReplyReplyController.loadingState.value as Success?) - ?.response ?? - []; + List list = _videoReplyReplyController.loadingState.value is Success + ? (_videoReplyReplyController.loadingState.value as Success) + .response + : []; list.insert(index + 1, replyInfo); _videoReplyReplyController.count.value += 1; _videoReplyReplyController.loadingState.value = LoadingState.success(list); } else { - List list = - (_videoReplyReplyController.loadingState.value as Success?) - ?.response ?? - []; + List list = _videoReplyReplyController.loadingState.value is Success + ? (_videoReplyReplyController.loadingState.value as Success) + .response + : []; list.insert(index + 1, ReplyItemModel.fromJson(res, '')); _videoReplyReplyController.count.value += 1; _videoReplyReplyController.loadingState.value =