I had the same problem with lists, now it is Map
.
What I would like to do
The following syntax is not Dart, as in it does not compile:
map?[key] ?? otherValue
If my map
was not a Map
but a List
, it would look like Günter pointed out here:
list?.elementAt(index) ?? otherValue
What I am searching for
I understand that map?[key]
is not valid syntax and therefore I am searching for something like elementAt
, which works for lists, for maps.
map?.valueFor(key) ?? otherValue
valueOf
That does obviously not yet exist. The problem has solutions and valueOf
might be a good one as well.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…