【问题标题】:Flutter confusing nested list with objectFlutter 将嵌套列表与对象混淆
【发布时间】:2020-03-08 16:36:42
【问题描述】:

这在 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]);
}

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    请尝试如下

    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]);
    }
    

    【讨论】:

      猜你喜欢
      • 2021-11-07
      • 2015-09-21
      • 2010-11-12
      • 1970-01-01
      • 2012-04-11
      • 1970-01-01
      • 1970-01-01
      • 2012-05-21
      • 2021-03-11
      相关资源
      最近更新 更多