I already went through this problem a while ago and searching the inner classes I found the following:
/**
* Creates a Map instance with the default implementation, [LinkedHashMap].
*
* This constructor is equivalent to the non-const map literal `<K,V>{}`.
*
* A `LinkedHashMap` requires the keys to implement compatible
* `operator==` and `hashCode`, and it allows null as a key.
* It iterates in key insertion order.
*/
In that hint it says that the Key must be compatible with the operator ==
and a List
is not compatible.
So whenever you do _mapList[[1, 'A']]
will receive a NULL in response.
Example
Follow an example to better understand:
void main() {
List a = [1, 2];
List b = [1, 2];
String c = "Teste";
String d = "Teste";
print(a == b); // return false
print(c == d); // return true
}
You can rotate on dartpad.
Workaround
When I came across this, I turned into my own List
in a String
and working with her that way...
You can enter in your Map
to Key as a text "[1, 'B']": "1B"
and if you need to work with Key in list format, just do
jsonDecode(Key); // Return [1, 'B'] (List)