@@ -285,7 +285,16 @@ class HtmlParser extends StatelessWidget {
285
285
newContext: newContext,
286
286
style: tree.style,
287
287
shrinkWrap: context.parser.shrinkWrap,
288
- children: tree.children.map ((tree) => parseTree (newContext, tree)).toList (),
288
+ children: tree.children
289
+ .expand ((tree) => [
290
+ parseTree (newContext, tree),
291
+ if (shrinkWrap &&
292
+ tree.style.display == Display .BLOCK &&
293
+ tree.element? .localName != "html" &&
294
+ tree.element? .localName != "body" )
295
+ TextSpan (text: "\n " ),
296
+ ])
297
+ .toList (),
289
298
),
290
299
);
291
300
} else if (tree.style.display == Display .LIST_ITEM ) {
@@ -827,7 +836,7 @@ class StyledText extends StatelessWidget {
827
836
@override
828
837
Widget build (BuildContext context) {
829
838
return SizedBox (
830
- width: calculateWidth (style.display, renderContext),
839
+ width: consumeExpandedBlock (style.display, renderContext),
831
840
child: Text .rich (
832
841
textSpan,
833
842
style: style.generateTextStyle (),
@@ -840,13 +849,10 @@ class StyledText extends StatelessWidget {
840
849
);
841
850
}
842
851
843
- double ? calculateWidth (Display ? display, RenderContext context) {
852
+ double ? consumeExpandedBlock (Display ? display, RenderContext context) {
844
853
if ((display == Display .BLOCK || display == Display .LIST_ITEM ) && ! renderContext.parser.shrinkWrap) {
845
854
return double .infinity;
846
855
}
847
- if (renderContext.parser.shrinkWrap) {
848
- return MediaQuery .of (context.buildContext).size.width;
849
- }
850
856
return null ;
851
857
}
852
858
}
0 commit comments