@@ -10,6 +10,7 @@ typedef CustomTextStyle = TextStyle Function(
1010 dom.Node node,
1111 TextStyle baseStyle,
1212);
13+ typedef CustomTextAlign = TextAlign Function (dom.Element elem);
1314typedef CustomEdgeInsets = EdgeInsets Function (dom.Node node);
1415typedef OnLinkTap = void Function (String url);
1516typedef OnImageTap = void Function ();
@@ -150,8 +151,9 @@ class HtmlRichTextParser extends StatelessWidget {
150151 this .onLinkTap,
151152 this .renderNewlines = false ,
152153 this .html,
153- this .customTextStyle,
154154 this .customEdgeInsets,
155+ this .customTextStyle,
156+ this .customTextAlign,
155157 this .onImageError,
156158 this .linkStyle = const TextStyle (
157159 decoration: TextDecoration .underline,
@@ -169,8 +171,9 @@ class HtmlRichTextParser extends StatelessWidget {
169171 final onLinkTap;
170172 final bool renderNewlines;
171173 final String html;
172- final CustomTextStyle customTextStyle;
173174 final CustomEdgeInsets customEdgeInsets;
175+ final CustomTextStyle customTextStyle;
176+ final CustomTextAlign customTextAlign;
174177 final ImageErrorListener onImageError;
175178 final TextStyle linkStyle;
176179 final ImageProperties imageProperties;
@@ -696,6 +699,9 @@ class HtmlRichTextParser extends StatelessWidget {
696699 // so if we have a block element, reset the parentElement to null
697700 parseContext.parentElement = null ;
698701 TextAlign textAlign = TextAlign .left;
702+ if (customTextAlign != null ) {
703+ textAlign = customTextAlign (node) ?? textAlign;
704+ }
699705
700706 EdgeInsets _customEdgeInsets;
701707 if (customEdgeInsets != null ) {
0 commit comments