Null-aware operator with Maps

前端 未结 5 860
迷失自我
迷失自我 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:17

    Or

    map != null ? map[key]: otherValue;
    

    which checks to see if the map is null before attempting to access the variable, which is the same as Günter's answer but checks first.

提交回复
热议问题