Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you center the label in a Flutter DataColumn widget?

I can center the DataCell in a DataRow but how do you do it for the DataColumn label?

I want the first DataColumn left justified and the rest centered. Wrapping the label in a Center widget does not take effect.

new DataColumn(
            label: Center(
              child: Text(statName,textAlign: TextAlign.center,
                style: TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold),),
            )
        );

Center Widget is not applied to Text child

like image 759
user1961 Avatar asked Jun 16 '19 00:06

user1961


2 Answers

Found how:

DataColumn(
    label: Expanded(
        child: Text(
  'Label',
  textAlign: TextAlign.center,
))),
like image 108
Rodrigo Boratto Avatar answered Nov 13 '22 04:11

Rodrigo Boratto


You may want to wrap the contents of the Label in a Center widget. There's also an Align widget that uses alignment: Alignment.center and your Text as it's child.

like image 2
Charles Jr Avatar answered Nov 13 '22 04:11

Charles Jr