【发布时间】:2022-11-17 05:54:11
【问题描述】:
我有一个看起来像这样的列表
var myOrder = [{handle: cpap-machines, order: 1}, {handle: cpap-masks, order: 2}, {handle: cpap-mask-parts, order: 3}, {handle: cpap-supplies, order: 4}, {handle: cpap-cleaning, order: 5}, {handle: cpap-batteries, order: 6}, {handle: oxygen-therapy, order: 7}, {handle: bundles, order: 8}]
和另一个列表,它是一个特定 Dart 模型的列表,但它确实包含这个匹配的关键字“handle”,称之为“Collection”
List<Collection> = [Collection(handle: 'cpap-machines'), Collection(handle: 'bundles'), Collection(handle: 'cpap-mask-parts'), Collection(handle: 'cpap-cleaning'), Collection(handle: 'cpap-supplies'), Collection(handle: 'cpap-batteries'), Collection(handle: 'cpap-masks'), Collection(handle: 'oxygen-therapy')]
它们保证具有相同的长度和相同的“句柄”值,但List<Collection> 列表需要跟在List<Map> 的“顺序”键之后。
我可以使用任何方法来实现这一目标?谢谢!
【问题讨论】:
-
在
myOrder中,参数cpap-machines是字符串还是您定义的其他对象?