I'm going to use a data table in my application.
In my page I have a background that this data table should be in a specific position (center maybe), but I don't know how to set alignment for that (data table).
Can anyone tell me how to solve this issue?
By default, there is no border. defaultVerticalAlignment => This property takes TableCellVerticalAlignment as the parameter value to sets the alignment of cells vertically in the table. textBaseline => Using this property we can specify a horizontal line uses to align text on the screen inside the Table widget.
To set the alignment of a widget in Flutter, you can wrap it as the child of an Align widget and pass the alignment argument to adjust the position.
Align Widget is the widget that is used to align its child within itself and optionally sizes itself based on the child's size. Align Widget is quite flexible and can change its size according to the size of its child.
child: Table(
children: [
TableRow(children: [
Center(child: Text("item 1"),),
Center(child: Text("item 2"),),
Center(child: Text("item 3"),),
Center(child: Text("item 4"),),
Center(child: Text("Edit"),),
]),
Working.
To align your text vertically in a table row you can wrap you Conent with TableCell and set the vertical Alignment parameter:
return TableRow(children: [
TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: Padding(
padding: const EdgeInsets.all(10),
child: Text('Hello World'),
),
),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With