flutter - flutter 朔迷离的嵌套列表与对象

标签 flutter dart

这在JS中可以正常工作,但是Dart(Flutter)心脏病发作。知道为什么吗??

void main() {
  var foo = [
    {
      "some": "thing",  // comment this line and it works ??
      "test": ["one", "two", "three"]
    }
  ];

  // The operator '[]' isn't defined for the class 'Object'
  print(foo[0]["test"][0]);
}

最佳答案

请尝试如下

void main() {
  List foo = [
    {
      "some": "thing",  // comment this line and it works ??
      "test": ["one", "two", "three"]
    }
  ];

  // The operator '[]' isn't defined for the class 'Object'
  print(foo[0]["test"][0]);
}

关于flutter - flutter 朔迷离的嵌套列表与对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60585522/

相关文章:

flutter - 使用Flutter RadioListTile的多项选择Qns测试应用

ios - Flutter:启用 Web 支持后...iOS 模拟器消失了

flutter - 抖动中的畸形消息是什么意思?什么时候以及为什么要来?

DartPad 不支持 ON 子句

flutter - 圆形图像文件

dart - Flutter 错误 - 内核二进制格式版本无效(找到 4 个,预期为 6 个)

ios - Flutter:由于集成了 firebase 和 Admob,无法构建 iOS 应用程序

flutter - 如何将可滚动小部件转换为图像?

user-interface - Flutter中如何调用上滑面板?

dart - 不支持的操作:无法评估 'in'表达式