flutterlayoutwidgetflutter-layoutflutter-row

Divide a Row into two equal halves in Flutter


I have a Row widget inside a Card, and I want to divide the Row perfectly in half the width of the card and put some centered text in each half. So the separation in half of the row has to be fixed and each text has to be centered in the half where it is. Here is an example:

enter image description here

Any ideas?


Solution

  • Try this

    Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Expanded(child: Center(child: TextButton(...))),
        VerticalDivider(width: 1.0),
        Expanded(child: Center(child: TextButton(...))),
      ],
    ),