如何在Dart中对MappedListIterable进行排序

如何在Dart中对MappedListIterable进行排序,dart,dart-html,Dart,Dart Html,我有一张地图,我不知道该怎么分类 调用sort方法时,我得到 异常:NoSuchMethodError:类“MappedListIterable”没有 实例方法“sort”。Receiver:“MappedListIterable”的实例 尝试调用:sortClosure:dynamic,dynamic=>dynamic 在调用一个Iterable之后,您将得到一个MappedListIterable 没有排序方法。此方法已启用 因此,首先需要通过调用.toList从MappedListIter

我有一张地图,我不知道该怎么分类

调用sort方法时,我得到

异常:NoSuchMethodError:类“MappedListIterable”没有 实例方法“sort”。Receiver:“MappedListIterable”的实例 尝试调用:sortClosure:dynamic,dynamic=>dynamic

在调用一个Iterable之后,您将得到一个MappedListIterable

没有排序方法。此方法已启用

因此,首先需要通过调用.toList从MappedListIterable获取列表

var i = [1, 3, 2].map((i) => i + 1);
// i is a MappedListIterable
// you can not call i.sort(...)

var l = i.toList();
l.sort(); // works
或在一行代码中:

var i = [1, 3, 2].map((i) => i + 1).toList()..sort();
在调用一个Iterable之后,您将得到一个MappedListIterable

没有排序方法。此方法已启用

因此,首先需要通过调用.toList从MappedListIterable获取列表

var i = [1, 3, 2].map((i) => i + 1);
// i is a MappedListIterable
// you can not call i.sort(...)

var l = i.toList();
l.sort(); // works
或在一行代码中:

var i = [1, 3, 2].map((i) => i + 1).toList()..sort();

一行..排序有效,但为什么是双点?为什么不呢?你能帮我理解吗?或者,请参阅任何文档链接。请参阅。排序返回空排序是在原地完成的,您不能将结果分配给变量。在一行中..排序可以工作,但为什么是双点?为什么不呢?你能帮我理解吗?或者,请参阅任何文档链接。请参阅。排序返回空排序是就地完成的,不能将结果分配给变量。