flutter - 颤振:对象/中心和列之间的空间不起作用:位置参数太多
问题描述
我是一个新手,我正在构建我的第一个应用程序。我的问题:我想为图标添加一些占位符(我还没有完成),没问题,但我不知道如何在它们之间添加空格。我想将它们居中,但看起来比这样:
位置参数太多:预期为 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,
),
],
),
],
),
),
),
提前谢谢!^^
解决方案
您需要使用命名参数,名称为child
:
body:
Container(
child: Center(
child: Column(
位置参数是没有名称的参数,例如child
但依赖于它们的位置。命名参数需要一个名称,它们的位置无关紧要。
在这种情况下Container
,并Center
有一个命名参数child
,用于指定树中的下一个 Widget。就像Column
有命名的参数一样children
。
推荐阅读
- flutter - 使用底部导航栏导航回页面时颤动通过底部导航栏选择的索引
- c# - C#,找不到原始签名者
- javascript - 我使用在本地工作的 Javascript 创建了一个网站,但当我上传到 github 时却没有尝试弄乱脚本
- sql - 查询获取单年记录
- apache-spark - 从同一个 csv 结构化流式写入和读取
- c# - JSON 结果不包含采用 0 个参数的构造函数
- session - 如何从 OpenAM 获取 authid
- javascript - 如何使用正则表达式来子串数字/数字字符串
- python - 在不知道 id 或 name 的情况下使用 beautifulsoup 填写表格
- javascript - 无法解构财产