首页 > 解决方案 > 颤振:对象/中心和列之间的空间不起作用:位置参数太多

问题描述

我是一个新手,我正在构建我的第一个应用程序。我的问题:我想为图标添加一些占位符(我还没有完成),没问题,但我不知道如何在它们之间添加空格。我想将它们居中,但看起来比这样:

位置参数太多:预期为 0,但找到了 1。尝试删除额外的位置参数,或指定命名参数的名称。

有人能帮我吗?这是我的代码(仅应用程序主体):

body:
    Container(   [<--- Here Bug "("]
      Center(    [<--- Here Bug "("]
       Column(
          children: <Widget> [
             Row(
              children: <Widget> [
                Placeholder( 
                  color: Colors.deepOrange,
                  strokeWidth: 3.5,
                  fallbackWidth: 75.0,
                  fallbackHeight: 75.0,
               ),

               Placeholder( 
                  color: Colors.indigo,
                  strokeWidth: 3.5,
                  fallbackWidth: 75.0,
                  fallbackHeight: 75.0,
                ),

                Placeholder( 
                  color: Colors.pink[200],
                  strokeWidth: 3.5,
                  fallbackWidth: 75.0,
                  fallbackHeight: 75.0,
                ),
              ],
               ),


               Row(
                children: <Widget> [
                  Placeholder( 
                   color: Colors.black,
                    strokeWidth: 3.5,
                   fallbackWidth: 75.0,
                   fallbackHeight: 75.0,
                ),

                 Placeholder( 
                   color: Colors.blueGrey[300],
                   strokeWidth: 3.5,
                   fallbackWidth: 75.0,
                   fallbackHeight: 75.0,
                ),

               Placeholder( 
                  color: Colors.red,
                 strokeWidth: 3.5,
                 fallbackWidth: 75.0,
                 fallbackHeight: 75.0,
                ),
               ],
              ),
            ],
          ),


     ),
 ),

截图(应用程序)

提前谢谢!^^

标签: flutterdart

解决方案


您需要使用命名参数,名称为child

body:
  Container(
    child: Center(
      child: Column(

位置参数是没有名称的参数,例如child但依赖于它们的位置。命名参数需要一个名称,它们的位置无关紧要。

在这种情况下Container,并Center有一个命名参数child,用于指定树中的下一个 Widget。就像Column有命名的参数一样children


推荐阅读