Skip to content

Commit 06a7f4a

Browse files
authored
Fix a bug that Embed could be together with Text (singerdmx#249)
1 parent ff93000 commit 06a7f4a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/src/widgets/text_line.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,14 @@ class TextLine extends StatelessWidget {
3737
Widget build(BuildContext context) {
3838
assert(debugCheckHasMediaQuery(context));
3939

40-
if (line.hasEmbed) {
41-
final embed = line.children.single as Embed;
40+
// In rare circumstances, the line could contain an Embed & a Text of
41+
// newline, which is unexpected and probably we should find out the
42+
// root cause
43+
final childCount = line.childCount;
44+
if (line.hasEmbed ||
45+
(childCount > 1 && line.children.first is Embed))
46+
{
47+
final embed = line.children.first as Embed;
4248
return EmbedProxy(embedBuilder(context, embed));
4349
}
4450

0 commit comments

Comments
 (0)