Reputation: 1018
I am using a text span widget in which I like to center all the text, instead of default alignment at the start.
Text.rich(
TextSpan(
text: "Go to your e-mail inbox and ",
style: TextStyle(
color: appBackground_color,
fontSize: 14,
fontWeight: FontWeight.w500),
children: <InlineSpan>[
TextSpan(
text: "activate your account",
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w700,
color: appBackground_color,
),
),
TextSpan(
text: " to proceed.",
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: appBackground_color),
),
],
),
),
How can i center the text in this widget?
Upvotes: 1
Views: 1134
Reputation: 305
Use RichText()
instead of Text.rich()
. Text.rich()
has no textAlign
parameter. Use like this:
RichText(
textAlign: TextAlign.center,
text: TextSpan(
text: "Go to your e-mail inbox and ",
children: <InlineSpan>[
TextSpan(),
TextSpan(),
],
),
),
But remember, RichText()
must have a width for the textAlign
to work. Like this:
Container(
width: double.infinity,
child: RichText(
//**
),
),
Upvotes: 4