fix: 嵌套中括号未识别最内层;匹配不上未显示原始内容;无标题或作者错误

This commit is contained in:
orz12
2024-06-17 01:12:16 +08:00
parent cba68c9e33
commit 7f755f1ba6

View File

@@ -80,9 +80,10 @@ class ChatItem extends StatelessWidget {
emojiMap[e['text']] = e['url'];
}
text.splitMapJoin(
RegExp(r"\[.+?\]"),
RegExp(r"\[[^\[\]]+\]"),
onMatch: (Match match) {
final String emojiKey = match[0]!;
print(emojiKey);
if (emojiMap.containsKey(emojiKey)) {
children.add(WidgetSpan(
child: NetworkImgLayer(
@@ -91,6 +92,15 @@ class ChatItem extends StatelessWidget {
src: emojiMap[emojiKey]!,
),
));
} else {
children.add(TextSpan(
text: emojiKey,
style: TextStyle(
color: textColor(context),
letterSpacing: 0.6,
height: 1.5,
),
));
}
return '';
},
@@ -174,7 +184,7 @@ class ChatItem extends StatelessWidget {
),
const SizedBox(height: 6),
Text(
content['title'],
content['title'] ?? "",
style: TextStyle(
letterSpacing: 0.6,
height: 1.5,
@@ -184,7 +194,7 @@ class ChatItem extends StatelessWidget {
),
const SizedBox(height: 1),
Text(
content['author'],
content['author'] ?? "",
style: TextStyle(
letterSpacing: 0.6,
height: 1.5,