@@ -78,6 +78,11 @@ class HtmlParser extends StatelessWidget {
7878 textSpan: parsedTree,
7979 style: cleanedTree.style,
8080 textScaleFactor: MediaQuery .of (context).textScaleFactor,
81+ renderContext: RenderContext (
82+ buildContext: context,
83+ parser: this ,
84+ style: Style .fromTextStyle (Theme .of (context).textTheme.bodyText2),
85+ ),
8186 );
8287 }
8388
@@ -319,6 +324,7 @@ class HtmlParser extends StatelessWidget {
319324 style: newContext.style.generateTextStyle (),
320325 ),
321326 style: newContext.style,
327+ renderContext: context,
322328 ),
323329 )
324330 ],
@@ -409,6 +415,7 @@ class HtmlParser extends StatelessWidget {
409415 [],
410416 ),
411417 style: newContext.style,
418+ renderContext: context,
412419 ),
413420 ),
414421 );
@@ -757,6 +764,7 @@ class ContainerSpan extends StatelessWidget {
757764 children: children,
758765 ),
759766 style: newContext.style,
767+ renderContext: newContext,
760768 ),
761769 );
762770 }
@@ -766,20 +774,20 @@ class StyledText extends StatelessWidget {
766774 final InlineSpan textSpan;
767775 final Style style;
768776 final double textScaleFactor;
777+ final RenderContext renderContext;
769778
770779 const StyledText ({
771780 this .textSpan,
772781 this .style,
773782 this .textScaleFactor = 1.0 ,
783+ this .renderContext,
774784 });
775785
776786 @override
777787 Widget build (BuildContext context) {
778788 return SizedBox (
779- width:
780- style.display == Display .BLOCK || style.display == Display .LIST_ITEM
781- ? double .infinity
782- : null ,
789+ width: (style.display == Display .BLOCK || style.display == Display .LIST_ITEM ) && renderContext.parser.shrinkWrap != true
790+ ? double .infinity : renderContext.parser.shrinkWrap == true ? MediaQuery .of (renderContext.buildContext).size.width : null ,
783791 child: Text .rich (
784792 textSpan,
785793 style: style.generateTextStyle (),
0 commit comments