在带有Dart和Flatter的类中声明贴图列表
我试着写一份工作清单代码>使用不同的语法,但仍然失败并给出错误在带有Dart和Flatter的类中声明贴图列表,dart,flutter,Dart,Flutter,我试着写一份工作清单使用不同的语法,但仍然失败并给出错误 type 'MappedListIterable' is not a subtype of type 'List<Map<String, Object>> ..... MappedListIterable is from dart:_internal List is from dart:core Mapis is from dart:core String is from dart:core Object is f
type 'MappedListIterable' is not a subtype of type 'List<Map<String, Object>> .....
MappedListIterable is from dart:_internal
List is from dart:core
Mapis is from dart:core
String is from dart:core
Object is from dart:core
.....
类型“MappedListIterable”不是类型“List”的子类型。。。。。
MappedListIterable来自dart:\u内部
列表来自dart:core
Mapis来自dart:core
这根线来自镖:核心
对象来自dart:core
.....
我想声明一个变量,它是一个Map列表,key是String,value是Object。我该怎么做
非常感谢您的帮助缺少一个.toList()
,无法将映射列表设置为正确的列表。如果调用.map()
、.where()
或列表上的类似函数,则会得到一个MappedListIterable
,并且只调用.toList()
(或迭代MappedListIterable
的其他方法)来具体化结果,因为这样的操作是延迟的,直到结果被实际访问为止
或者你也可以改变
List<Map<String, Object>> _work;
List\u工作;
到
Iterable\u工作;
使用Dart 2.x您还可以尝试将MappedListIterable
转换为List
并返回toList()
以简单的单行命令解决问题:
(dictionary['key'] as List).map((item)=> {}).toList();
请向我们展示发生错误的代码段。
(dictionary['key'] as List).map((item)=> {}).toList();