飞镖列表中三个点(...)的用途是什么? [英] What's the usage of three dots (...) in dart List?

查看:62
本文介绍了飞镖列表中三个点(...)的用途是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码是这样写的,但是它给出了一个错误:

I have my code written like this but it gives an error saying:

错误:不能将类型为列表"的值分配给类型为小部件"的变量.

Error: A value of type 'List' can't be assigned to a variable of type 'Widget'.

Column(
  children: [
    Question(
      questions[_questionIndex]['questionText'],
    ),
    ...(questions[_questionIndex]['answers'] as List<String>)
        .map((answer) {
      return Answer(_answerQuestion, answer);
    }).toList()
  ],
)

推荐答案

我知道了我的问题.我的Flutter SDK尚未升级.运行flutter doctor命令并整理出缺少的更新.而且语法现在似乎可以正常工作.

I've figured out my issue. My flutter SDK wasn't upgraded. Ran flutter doctor command and sorted out the missing updates. And the syntax seems to be working fine now.

flutter upgrade

Dart版本(必需)> = 2.3

Dart version (required) >= 2.3

重新启动IDE(如果问题仍然存在)

Restart IDE (if the problem persists)

这篇关于飞镖列表中三个点(...)的用途是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆