mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
fix: whisper: null check
related #217 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import 'package:PiliPlus/common/widgets/http_error.dart';
|
import 'package:PiliPlus/common/widgets/http_error.dart';
|
||||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||||
|
import 'package:PiliPlus/models/msg/session.dart';
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
@@ -161,7 +162,8 @@ class _WhisperPageState extends State<WhisperPage> {
|
|||||||
}
|
}
|
||||||
Map data = snapshot.data as Map;
|
Map data = snapshot.data as Map;
|
||||||
if (data['status']) {
|
if (data['status']) {
|
||||||
List sessionList = _whisperController.sessionList;
|
List<SessionList> sessionList =
|
||||||
|
_whisperController.sessionList;
|
||||||
return Obx(
|
return Obx(
|
||||||
() => sessionList.isEmpty
|
() => sessionList.isEmpty
|
||||||
? const SizedBox()
|
? const SizedBox()
|
||||||
@@ -171,7 +173,7 @@ class _WhisperPageState extends State<WhisperPage> {
|
|||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
itemBuilder: (context, int i) {
|
itemBuilder: (context, int i) {
|
||||||
dynamic content =
|
dynamic content =
|
||||||
sessionList[i]?.lastMsg?.content;
|
sessionList[i].lastMsg?.content;
|
||||||
if (content == null || content == "") {
|
if (content == null || content == "") {
|
||||||
content = '不支持的消息类型';
|
content = '不支持的消息类型';
|
||||||
} else {
|
} else {
|
||||||
@@ -252,27 +254,33 @@ class _WhisperPageState extends State<WhisperPage> {
|
|||||||
'',
|
'',
|
||||||
if (sessionList[i].accountInfo?.mid !=
|
if (sessionList[i].accountInfo?.mid !=
|
||||||
null)
|
null)
|
||||||
'mid': sessionList[i]
|
'mid':
|
||||||
.accountInfo
|
'${sessionList[i].accountInfo?.mid}',
|
||||||
.mid
|
|
||||||
.toString(),
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
leading: Badge(
|
leading: Builder(builder: (context) {
|
||||||
isLabelVisible:
|
Widget buildAvatar() => NetworkImgLayer(
|
||||||
sessionList[i].unreadCount > 0,
|
width: 45,
|
||||||
label: Text(
|
height: 45,
|
||||||
" ${sessionList[i].unreadCount.toString()} "),
|
type: 'avatar',
|
||||||
alignment: Alignment.topRight,
|
src: sessionList[i]
|
||||||
child: NetworkImgLayer(
|
.accountInfo
|
||||||
width: 45,
|
?.face ??
|
||||||
height: 45,
|
"",
|
||||||
type: 'avatar',
|
);
|
||||||
src: sessionList[i].accountInfo?.face ??
|
return sessionList[i].unreadCount != null
|
||||||
"",
|
? Badge(
|
||||||
),
|
isLabelVisible:
|
||||||
),
|
sessionList[i].unreadCount! >
|
||||||
|
0,
|
||||||
|
label: Text(
|
||||||
|
" ${sessionList[i].unreadCount} "),
|
||||||
|
alignment: Alignment.topRight,
|
||||||
|
child: buildAvatar(),
|
||||||
|
)
|
||||||
|
: buildAvatar();
|
||||||
|
}),
|
||||||
title: Text(
|
title: Text(
|
||||||
sessionList[i].accountInfo?.name ?? ""),
|
sessionList[i].accountInfo?.name ?? ""),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
@@ -287,18 +295,24 @@ class _WhisperPageState extends State<WhisperPage> {
|
|||||||
.colorScheme
|
.colorScheme
|
||||||
.outline),
|
.outline),
|
||||||
),
|
),
|
||||||
trailing: Text(
|
trailing:
|
||||||
Utils.dateFormat(
|
sessionList[i].lastMsg?.timestamp !=
|
||||||
sessionList[i].lastMsg.timestamp,
|
null
|
||||||
formatType: "day"),
|
? Text(
|
||||||
style: Theme.of(context)
|
Utils.dateFormat(
|
||||||
.textTheme
|
sessionList[i]
|
||||||
.labelSmall!
|
.lastMsg!
|
||||||
.copyWith(
|
.timestamp,
|
||||||
color: Theme.of(context)
|
formatType: "day"),
|
||||||
.colorScheme
|
style: Theme.of(context)
|
||||||
.outline),
|
.textTheme
|
||||||
),
|
.labelSmall!
|
||||||
|
.copyWith(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.outline),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
separatorBuilder:
|
separatorBuilder:
|
||||||
|
|||||||
Reference in New Issue
Block a user