How can I justify text with Flutter markdown?

It becomes possible to set up proper text alignment with flutter_markdown.

    var style = MarkdownStyleSheet(
        textAlign: WrapAlignment.center,
        h1Align: WrapAlignment.center,
      );
    Markdown(
        styleSheet: style,
        data: '# header1 is center-aligned\ntext body is also center-aligned'
    );

You can customized your styles with all the other optional parameters provided by MarkdownStyleSheet class.


It's not available for now to change text alignment in flutter_markdown 0.2.0. You must contact the authors of this plugin to request this feature.

But if you need fast fix, you can add textAlign: TextAlign.center attribute in source code of this file: https://github.com/flutter/flutter_markdown/blob/master/lib/src/builder.dart

Line of code: 345

mergedTexts.add(new RichText(text: mergedSpan, textAlign: TextAlign.center));

Result:

flutter_markdown alignment center

For more elegant way you must clone git repository of this plugin, attach to your project directly and work to add text alignment feature on your own.