How to center column and row item in Flutter?

后端 未结 3 1793
小鲜肉
小鲜肉 2021-02-01 14:46

I have a small currency table. I didn\'t use grid. I used Column and rows. Problem is that items in rows is not showing in center as shown below in the Excel example. What widge

相关标签:
3条回答
  • 2021-02-01 15:11

    If you want the whole table to be Centered, use the mainAxisAlignment property of Column.

    Column

    mainAxisAlignment: MainAxisAlignment.center //Center Column contents vertically,
    crossAxisAlignment: CrossAxisAlignment.center //Center Column contents horizontally,
    

    Row

    mainAxisAlignment: MainAxisAlignment.center //Center Row contents horizontally,
    crossAxisAlignment: CrossAxisAlignment.center //Center Row contents vertically,
    
    0 讨论(0)
  • 2021-02-01 15:11

    If you want it to be like in the picture, use

    mainAxisAlignment: MainAxisAlignment.spaceEvenly
    
    0 讨论(0)
  • 2021-02-01 15:21

    You can use Spacer if you want fine grain control.

    Column(
      children: <Widget>[
        Spacer(), // 1st spacer
        Widget1(),
        Widget2(),
        Spacer(), // 2nd spacer
      ],
    )
    

    You can change flex too using Spacer(flex:2)

    0 讨论(0)
提交回复
热议问题