Lists in Dart are not equal based on their elements.
You can use Mapwith custom equality function. There package:collection/equality.dartis equality in the lists defined in , so you can do:
import "package:collection/equality.dart";
main() {
const eq = const ListEquality();
var map = new Map(equals: eq.equals, hashCode: eq.hash, isValidKey: eq.isValidKey);
map[[1,2]] = 42;
print(map[[1,2]]);
}
This will still not allow you to use a map literal.
source
share