Null-aware operator with Maps

前端 未结 5 857
迷失自我
迷失自我 2020-12-18 19:42

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

5条回答
  •  执念已碎
    2020-12-18 20:10

    This works:

    (map ?? const {})[key] ?? otherValue;
    

    Because the key will fallback to accessing an empty Map, which will always return null.

提交回复
热议问题