Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Table Alignment in Flutter?

Tags:

flutter

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?

like image 475
ElhamKeshavarz Avatar asked Sep 19 '18 15:09

ElhamKeshavarz


People also ask

How do you align a table in Flutter?

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.

How do you change the alignment on Flutter?

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.

How does alignment work in Flutter?

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.


2 Answers

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.

like image 113
Vinicius Fernandes Avatar answered Sep 28 '22 05:09

Vinicius Fernandes


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'),
        ),
    ),
like image 20
Julius Faubel Avatar answered Sep 28 '22 06:09

Julius Faubel