I have a text widget (in a container). The text within the widget always appears left-aligned.
Container(decoration: myBoxDecoration(),
child: Row(children: <Widget>[
Center(child: Text('Historical Information Below (latest Results at top)', textAlign: TextAlign.center,))],),
),
I've used the parameter:
TextAlign: TextAlign.center
but alas, this is of no avail.
I've even added this Text widget in a Center widget, and that has done nothing.
What am I doing wrong?
This happens because you have Text
widget inside Row
widget.
So, add mainAxisAlignment: MainAxisAlignment.center
to Row
Container(
decoration: myBoxDecoration(),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Center(
child: Text(
'Historical Information Below (latest Results at top)',
textAlign: TextAlign.center,
),
),
],
),
)
or remove Row
Container(
decoration: myBoxDecoration(),
child: Center(
child: Text(
'Historical Information Below (latest Results at top)',
textAlign: TextAlign.center,
),
),
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.