List<List<int>> intArr = [
[0, 0],
[1, 1],
[1, 1],
];
I want to get an output like below in the above list. How can I do it?
[0,0],[1,1]
最佳答案
import 'package:collection/collection.dart'; // Must be imported
/// Below codes must be inside a function
List<List<int>> intArr = [[0, 0],[1, 1],[1, 1]];
List<List<int>> newList = [];
Function eq = const ListEquality().equals;
for (var i in intArr) {
if (!newList.any((v) => eq(v, i))) {
newList.add(i);
}
}
我引用了 Jahidul 的评论。
关于flutter - 如何使我的列表在 Dart 语言中独一无二?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70295794/