【问题标题】:Flutter ListTile missing a required argumentFlutter ListTile 缺少必需的参数
【发布时间】:2019-02-20 01:01:17
【问题描述】:

我正在编写一个包含 ListView 的简单 Flutter 应用程序。按照教程,我的 ListView 正在使用构建器,如下所示:

ListView myListItems() {
  return ListView.builder(
    itemCount: count,
    itemBuilder: (BuildContext context, int position) {
      return Card(
        color: Colors.white,
        elevation: 2.0,
         child: ListTile( // error shows up here
           leading: const Icon(Icons.event_seat),
           title: const Text('Here is some text'),
         )
      );
    },
  );
}

...但是那句话,

“child: ListTile(” 括号中有一个错误,说“需要 1 个必需的参数,但找到 0 个。dart(not_enough_required_arguments)”

知道我错过了什么吗?

【问题讨论】:

    标签: flutter


    【解决方案1】:

    这可能是由于 Flutter SDK 损坏,因为您的代码是正确的。

    尝试在 Flutter SDK 文件夹中运行此命令:

    git clean -xfd
    git stash save --keep-index
    git stash drop
    git pull
    flutter doctor

    【讨论】:

    • 我跑了,现在我到处都是红色的波浪线!
    • 尝试清理和重建。如果仍然存在,请尝试全新安装 Flutter SDK。
    • 抱歉,我该如何在 VS Code 中做到这一点?
    • Flutter clean, build.Wait,你在哪里运行了上面的命令?在你的 Flutter 项目文件夹中?
    • 来自 VS Code 中的 Powershell。抱歉,我是新手。
    猜你喜欢
    • 1970-01-01
    • 2021-11-05
    • 2018-10-28
    • 2018-12-01
    • 2016-06-29
    • 2018-06-20
    • 2020-09-27
    • 1970-01-01
    相关资源
    最近更新 更多