1

I need to create the following:

https://i.stack.imgur.com/zziYr.png

I could do it with code:

Row(
  children: <Widget>[
    Container(
      width: 30
    ),
    Column(
      children: <Widget>[
        Text("label"),
        Container(
          width: screenSize.width - 30, // <- this is problem
          child: Row(
            children: <Widget>[
              Expanded( child: TextField() ),
              Expanded( child: TextField() ),
            ],
          ),
        ),
      ],
    ),
  ],
);

Is it possible to do it in a different way, namely the line width: screenSize.width - 30?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574

2 Answers2

1

You can use crossAxisAlignment inside Column widget and make it Stretch to get all remaining width in screen

Row(
children: <Widget>[
Container(
  width: 30
),
Column(
crossAxisAlignment: CrossAxisAlignment.stretch, // <- Add this
  children: <Widget>[
    Text("label"),
    Container(
      child: Row(
        children: <Widget>[
          Expanded( child: TextField() ),
          Expanded( child: TextField() ),
        ],
      ),
    ),
  ],
),],);

[Please read official flutter documentation of Column widget]

Column Widget

CrossAxisAlignment

Ahmed Saied
  • 251
  • 2
  • 9
0

Solution

Row(
  children: <Widget>[
    Container(
      color: Colors.red,
      width: 50,
    ),
    Expanded(
      child: Column(
        children: <Widget>[
          Text("label"),
          Expanded(
            child: Row(
              children: <Widget>[
                Expanded(
                  child: TextField()
                ),
                Expanded(
                  child: TextField()
                ),
              ],
            ),
          ),
        ],
      ),
    ),
  ],
);

Explanation

It is about where you place Expanded instances.
You have a row, which can fill its parent if it included an Expanded child. So we defined the size of one of its children (Container), and the other is simply Expanded. The same goes for the Column child ..

Maybe starting with a simpler example makes it easier to understand. Please refer to this useful answer.

Output

Resulted pic

P.S. Welcome to StackOverFlow, Dmitry!

Smily
  • 2,732
  • 1
  • 15
  • 20