@@ -10,6 +10,7 @@ typedef CustomTextStyle = TextStyle Function(
10
10
dom.Node node,
11
11
TextStyle baseStyle,
12
12
);
13
+ typedef CustomTextAlign = TextAlign Function (dom.Element elem);
13
14
typedef CustomEdgeInsets = EdgeInsets Function (dom.Node node);
14
15
typedef OnLinkTap = void Function (String url);
15
16
typedef OnImageTap = void Function ();
@@ -150,8 +151,9 @@ class HtmlRichTextParser extends StatelessWidget {
150
151
this .onLinkTap,
151
152
this .renderNewlines = false ,
152
153
this .html,
153
- this .customTextStyle,
154
154
this .customEdgeInsets,
155
+ this .customTextStyle,
156
+ this .customTextAlign,
155
157
this .onImageError,
156
158
this .linkStyle = const TextStyle (
157
159
decoration: TextDecoration .underline,
@@ -169,8 +171,9 @@ class HtmlRichTextParser extends StatelessWidget {
169
171
final onLinkTap;
170
172
final bool renderNewlines;
171
173
final String html;
172
- final CustomTextStyle customTextStyle;
173
174
final CustomEdgeInsets customEdgeInsets;
175
+ final CustomTextStyle customTextStyle;
176
+ final CustomTextAlign customTextAlign;
174
177
final ImageErrorListener onImageError;
175
178
final TextStyle linkStyle;
176
179
final ImageProperties imageProperties;
@@ -696,6 +699,9 @@ class HtmlRichTextParser extends StatelessWidget {
696
699
// so if we have a block element, reset the parentElement to null
697
700
parseContext.parentElement = null ;
698
701
TextAlign textAlign = TextAlign .left;
702
+ if (customTextAlign != null ) {
703
+ textAlign = customTextAlign (node) ?? textAlign;
704
+ }
699
705
700
706
EdgeInsets _customEdgeInsets;
701
707
if (customEdgeInsets != null ) {
0 commit comments