Reputation: 9369
I like to know, how to align text vertical in Text Widget. There is an attribute called textAlign. It will align the text center of both vertical and horizontal. So I need to algin text only in vertical.
When I set TextAlign.center,
Upvotes: 0
Views: 284
Reputation: 104
wrap your text inside a Align widget,
so you can control the alignment in any direction horizontal or vertical or both
Container(
height: 48,
width: double.infinity,
decoration:
BoxDecoration(border: Border.all(width: 1, color: Colors.blue)),
child: const Align(
alignment: Alignment.centerLeft,
child: Text(
'Hello World',
),
),
),
Upvotes: 0
Reputation: 8978
You may also use Row() Flutter or Column() and use their crossAxisAlignment
and mainAxisAlignment
for alignment of the widget
Column(
crossAixsAlignment: CrossAxisAlignment.center,
children: <Widget>[ Text() ]
)
Upvotes: 1