Skip to content

Commit 2039240

Browse files
committed
Implement li leading char as TextSpan rather than separate widget
1 parent 38a7739 commit 2039240

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

lib/rich_text_parser.dart

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,12 @@ class BlockText extends StatelessWidget {
8383
final RichText child;
8484
final EdgeInsets padding;
8585
final EdgeInsets margin;
86-
final String leadingChar;
8786
final Decoration decoration;
8887

8988
BlockText({
9089
@required this.child,
9190
this.padding,
9291
this.margin,
93-
this.leadingChar = '',
9492
this.decoration,
9593
});
9694

@@ -101,13 +99,7 @@ class BlockText extends StatelessWidget {
10199
padding: this.padding,
102100
margin: this.margin,
103101
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-
),
102+
child: child,
111103
);
112104
}
113105
}
@@ -848,12 +840,13 @@ class HtmlRichTextParser extends StatelessWidget {
848840
left: parseContext.indentLevel * indentSize, top: 3.0),
849841
child: RichText(
850842
text: TextSpan(
851-
text: '',
852-
style: nextContext.childStyle,
853-
children: <TextSpan>[],
843+
text: '$leadingChar ',
844+
style: DefaultTextStyle.of(buildContext).style,
845+
children: <TextSpan>[
846+
TextSpan(text: '', style: nextContext.childStyle)
847+
],
854848
),
855849
),
856-
leadingChar: '$leadingChar ',
857850
);
858851
parseContext.rootWidgetList.add(blockText);
859852
nextContext.parentElement = blockText.child.text;

0 commit comments

Comments
 (0)