Skip to content

Commit 7a44386

Browse files
committed
fix: handle potential null values in decode parameters and improve message parsing logic
1 parent 3666eae commit 7a44386

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

lib/model/message.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,5 +271,8 @@ extension BatchMessage on Message {
271271

272272
List<String> get contentAndTails => content.split(Config.userMsgModifierSep);
273273

274+
// TODO: 应该作为 msg 的内存值, 不要在 Build 方法中调用, 如果 msg 没有这个值, 调用并解析, 如果 msg 这个值不为空, 直接取值
275+
276+
// TODO: @wangce 检查一下什么时候这个方法会被传递空值
274277
List<SamplerAndPenaltyParam> get parsedDecodeParams => SamplerAndPenaltyParamWithString.fromRawDecodeParams(rawDecodeParams ?? "");
275278
}

lib/widgets/chat/batch_message_content.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ class _BatchMessageContentState extends ConsumerState<BatchMessageContent> {
178178

179179
class _MarkdownBody extends ConsumerWidget {
180180
final String data;
181+
181182
final SamplerAndPenaltyParam? decodeParam;
182183

183184
const _MarkdownBody({required this.data, this.decodeParam});
@@ -206,7 +207,7 @@ class _MarkdownBody extends ConsumerWidget {
206207

207208
final s = S.of(context);
208209

209-
final displayText = s.decode_param + s.hyphen + decodeParam!.displayName;
210+
final displayText = s.decode_param + s.hyphen + (decodeParam?.displayName ?? "unknown");
210211

211212
final Widget? decodeParamWidget = decodeParam != null
212213
? Align(

0 commit comments

Comments
 (0)