|
|
|
@ -39,12 +39,17 @@ class TextLine extends StatelessWidget { |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
assert(debugCheckHasMediaQuery(context)); |
|
|
|
|
|
|
|
|
|
// In rare circumstances, the line could contain an Embed & a Text of |
|
|
|
|
// newline, which is unexpected and probably we should find out the |
|
|
|
|
// root cause |
|
|
|
|
final childCount = line.childCount; |
|
|
|
|
if (line.hasEmbed || (childCount > 1 && line.children.first is Embed)) { |
|
|
|
|
final embed = line.children.first as Embed; |
|
|
|
|
if (line.hasEmbed) { |
|
|
|
|
if (line.childCount == 1) { |
|
|
|
|
// For video, it is always single child |
|
|
|
|
final embed = line.children.single as Embed; |
|
|
|
|
return EmbedProxy(embedBuilder(context, embed, readOnly)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// The line could contain more than one Embed & more than one Text |
|
|
|
|
// TODO: handle more than one Embed |
|
|
|
|
final embed = |
|
|
|
|
line.children.firstWhere((child) => child is Embed) as Embed; |
|
|
|
|
return EmbedProxy(embedBuilder(context, embed, readOnly)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|