flutter - Flutter 将嵌套列表与对象混淆
问题描述
这在 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]);
}
推荐阅读
- tinymce - 如何找出 HCL Connections 中安装了哪个 TinyMCE 版本?
- javascript - Node.js 和 OracleDB。从数据库中选择对象
- asp.net - 发布我的项目后,“不合并”选项不起作用
- wpf - 需要在鼠标单击时聚焦放置在滚动查看器内的网格
- jquery - jQuery $.get() 不工作并调用 express get
- angular - 基于打字稿数据对象的角表行跨度和列跨度
- excel - 覆盖结果行,同时将行粘贴到目标工作表
- javascript - 如何根据名称合并数组javascript中的重复对象值
- date - 如何在颤振中进行年龄验证
- linux - 每次在 kube 中重新启动 pod 时,它都会更改 .ssh 文件夹的权限