@@ -83,31 +83,25 @@ class BlockText extends StatelessWidget {
8383 final RichText child;
8484 final EdgeInsets padding;
8585 final EdgeInsets margin;
86- final String leadingChar;
8786 final Decoration decoration;
87+ final bool shrinkToFit;
8888
8989 BlockText ({
9090 @required this .child,
91+ @required this .shrinkToFit,
9192 this .padding,
9293 this .margin,
93- this .leadingChar = '' ,
9494 this .decoration,
9595 });
9696
9797 @override
9898 Widget build (BuildContext context) {
9999 return Container (
100- width: double .infinity,
100+ width: shrinkToFit ? null : double .infinity,
101101 padding: this .padding,
102102 margin: this .margin,
103103 decoration: this .decoration,
104- child: Row (
105- crossAxisAlignment: CrossAxisAlignment .start,
106- children: < Widget > [
107- leadingChar.isNotEmpty ? Text (leadingChar) : Container (),
108- Expanded (child: child),
109- ],
110- ),
104+ child: child,
111105 );
112106 }
113107}
@@ -155,7 +149,7 @@ class ParseContext {
155149
156150class HtmlRichTextParser extends StatelessWidget {
157151 HtmlRichTextParser ({
158- @required this .width ,
152+ this .shrinkToFit ,
159153 this .onLinkTap,
160154 this .renderNewlines = false ,
161155 this .html,
@@ -175,7 +169,7 @@ class HtmlRichTextParser extends StatelessWidget {
175169
176170 final double indentSize = 10.0 ;
177171
178- final double width ;
172+ final bool shrinkToFit ;
179173 final onLinkTap;
180174 final bool renderNewlines;
181175 final String html;
@@ -426,6 +420,7 @@ class HtmlRichTextParser extends StatelessWidget {
426420 ));
427421 }
428422 BlockText blockText = BlockText (
423+ shrinkToFit: shrinkToFit,
429424 margin: EdgeInsets .only (
430425 top: 8.0 ,
431426 bottom: 8.0 ,
@@ -439,8 +434,10 @@ class HtmlRichTextParser extends StatelessWidget {
439434 );
440435 parseContext.rootWidgetList.add (blockText);
441436 } else {
442- parseContext.rootWidgetList
443- .add (BlockText (child: RichText (text: span)));
437+ parseContext.rootWidgetList.add (BlockText (
438+ child: RichText (text: span),
439+ shrinkToFit: shrinkToFit,
440+ ));
444441 }
445442
446443 // this allows future items to be added as children of this item
@@ -607,6 +604,7 @@ class HtmlRichTextParser extends StatelessWidget {
607604 } else {
608605 // start a new block element for this link and its text
609606 BlockText blockElement = BlockText (
607+ shrinkToFit: shrinkToFit,
610608 margin: EdgeInsets .only (
611609 left: parseContext.indentLevel * indentSize, top: 10.0 ),
612610 child: RichText (text: span),
@@ -856,16 +854,18 @@ class HtmlRichTextParser extends StatelessWidget {
856854 leadingChar = parseContext.listCount.toString () + '.' ;
857855 }
858856 BlockText blockText = BlockText (
857+ shrinkToFit: shrinkToFit,
859858 margin: EdgeInsets .only (
860859 left: parseContext.indentLevel * indentSize, top: 3.0 ),
861860 child: RichText (
862861 text: TextSpan (
863- text: '' ,
864- style: nextContext.childStyle,
865- children: < TextSpan > [],
862+ text: '$leadingChar ' ,
863+ style: DefaultTextStyle .of (buildContext).style,
864+ children: < TextSpan > [
865+ TextSpan (text: '' , style: nextContext.childStyle)
866+ ],
866867 ),
867868 ),
868- leadingChar: '$leadingChar ' ,
869869 );
870870 parseContext.rootWidgetList.add (blockText);
871871 nextContext.parentElement = blockText.child.text;
@@ -926,6 +926,7 @@ class HtmlRichTextParser extends StatelessWidget {
926926 ));
927927 }
928928 BlockText blockText = BlockText (
929+ shrinkToFit: shrinkToFit,
929930 margin: node.localName != 'body'
930931 ? _customEdgeInsets ??
931932 EdgeInsets .only (
0 commit comments