Specific min and max size for expanded widgets in Column

后端 未结 3 1009
闹比i
闹比i 2021-01-11 22:21

I have a Column with a set of Expanded widgets.

Is there a way to control the range in which they expand? I want one widget to expand only to a certain size and make

3条回答
  •  Happy的楠姐
    2021-01-11 22:41

    You are looking for ConstrainedBox.

    You can create a List of Widgets with both ConstrainedBox and Expanded, as following:

    Row(
      children: [
        ConstrainedBox(
          child: Container(color: Colors.red),
          constraints: BoxConstraints(
            minWidth: 50,
            maxWidth: 100,
          ),
        ),
        Expanded(
          child: Container(color: Colors.green),
        ),
        Expanded(
          child: Container(color: Colors.blue),
        ),
      ],
    ),
    

提交回复
热议问题