Make container widget fill parent vertically

前端 未结 6 982
天命终不由人
天命终不由人 2020-12-25 09:38

TL;DR Need the container to fill the vertical space so that it can act as a ontap listener. Have tried most solutions but nothing seems to work.

So what I am trying

6条回答
  •  青春惊慌失措
    2020-12-25 10:24

    The trick is to combine an IntrinsicHeight widget and a Row with crossAxisAlignment: CrossAxisAlignment.stretch

    This force the children of Row to expand vertically, but Row will take the least amount of vertical space possible.

    Card(
      child: IntrinsicHeight(
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            Container(
              width: 20.0,
              color: Colors.amber,
            ),
            // Expanded(...)
          ],
        ),
      )
    )
    

提交回复
热议问题