学无先后,达者为师

网站首页 编程语言 正文

flutter The argument type ‘String?‘ can‘t be assigned to the parameter type ‘String‘.

作者:_花开富贵 更新时间: 2022-03-14 编程语言
The argument type 'String?' can't be assigned to the parameter type 'String'.

Change the return type of statusCode to String and provide a default value.

String get statusCode => statusCodes[this] ?? '';

When accessing a map, there is a chance that you will get a null return value if the key does not exist in the map. Simply providing a default value will allow this code to compile. That default value should never be used unless you add something to the enum without adding a value to the map as well.

stackoverflow

原文链接:https://blog.csdn.net/sinat_42338962/article/details/122330655

栏目分类
最近更新