Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
User interface 在颤振中设置列宽度_User Interface_Dart_Flutter - Fatal编程技术网

User interface 在颤振中设置列宽度

User interface 在颤振中设置列宽度,user-interface,dart,flutter,User Interface,Dart,Flutter,我需要在颤振中设置一个列宽,我必须做一个有3个部分的布局,一个应该是屏幕的20%,另一个60%,最后一个20%。 我知道这3列应该排成一行,但我不知道如何设置大小,当我这样做时,这3列的大小相同 我将非常感谢您的反馈。我建议您像这样使用Flex而不是硬编码尺寸 Row( children: <Widget>[ Expanded( flex: 2, // 20% child: Container(color: Colo

我需要在颤振中设置一个列宽,我必须做一个有3个部分的布局,一个应该是屏幕的20%,另一个60%,最后一个20%。 我知道这3列应该排成一行,但我不知道如何设置大小,当我这样做时,这3列的大小相同


我将非常感谢您的反馈。

我建议您像这样使用
Flex
而不是硬编码尺寸

Row(
      children: <Widget>[
        Expanded(
          flex: 2, // 20%
          child: Container(color: Colors.red),
        ),
        Expanded(
          flex: 6, // 60%
          child: Container(color: Colors.green),
        ),
        Expanded(
          flex: 2, // 20%
          child: Container(color: Colors.blue),
        )
      ],
    )
行(
儿童:[
扩大(
弹性:2,//20%
子:容器(颜色:Colors.red),
),
扩大(
弹性:6,//60%
子容器(颜色:Colors.green),
),
扩大(
弹性:2,//20%
子:容器(颜色:Colors.blue),
)
],
)
这将产生如下结果,
限制
列的
宽度可以是


  • 限制
    列的
    宽度
    ,使用
    SizedBox

    SizedBox(
      width: 100, // set this
      child: Column(...),
    )
    
  • 2(A)。限制
    列中
    子项
    宽度
    无硬编码值

    Row(
      children: <Widget>[
        Expanded(
          flex: 3, // takes 30% of available width 
          child: Child1(),
        ),
        Expanded(
          flex: 7, // takes 70% of available width  
          child: Child2(),
        ),
      ],
    )
    
    Row(
      children: <Widget>[
        SizedBox(
          width: 100, // hard coding child width
          child: Child1(),
        ),
        SizedBox(
          width: 200, // hard coding child width
          child: Child2(),
        ),
      ],
    )