I want to make RichText align to the left.
I tried use Container, Row, Column, Flexible, Expanded widgets, but nothing helped me.
Future getAuthorsDialog(BuildContext context) {
return showDialog<String>(
context: context,
builder: (BuildContext context) => Dialog(
insetPadding: const EdgeInsets.symmetric(vertical: 90.0),
child: Column(
children: <Widget>[
const SizedBox(height: 8.0),
RichText(
textAlign: TextAlign.left,
text: const TextSpan(
text: 'Mod: ',
style: TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.bold
),
children: [
TextSpan(
text: 'Tester',
style: TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.w600
)
),
]
)
),
]),
),
);
}
2
Answers
Your solution show me on second picture, but Mod: Tester must be have left align.
Your RichText widget is being affected by the Column widget. By default, Column will align children in the centre.
So you can adjust the entire column to be left:
Or if you want just the RichText widget to be left aligned, then wrap RichText in an Align widget like this:
Note, both of these puts text all the way to the left so probably you should add padding to the left of the text. But I will leave that as an exercise for you 🙂