I started using flutter markdown, however I'd like to justify the content, and I couldn't until now.
I tried using a Center
and Alignment
but didn't work.
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
class OutsideBankHourDescription extends StatelessWidget {
@override
Widget build(BuildContext context) {
String text =
"Antecipações em __horários__ bancários acontecem em 1h na média. __Fora do horário bancário__ o saldo estará em sua conta __no dia seguinte.__";
return Expanded(
child: Container(
alignment: Alignment.center,
child: Markdown(
styleSheet: MarkdownStyleSheet.fromTheme(Theme.of(context)),
data: text,
),
),
);
}
}
To center align the text in a Text widget, provide textAlign property with value TextAlign. center .
How do you align paragraph text in Flutter? textAlign: Flutter facilitates the alignment of text horizontally inside its parent widget's boundary using textAlign property. textDirection: textDirection is used to specify the direction of the text inside a Text Widget say ltr (left-to-right) or rtl (right to left).
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With