【发布时间】:2022-01-02 11:25:29
【问题描述】:
谁能告诉我如何修复类名的错误实例?
【问题讨论】:
标签: flutter dart overriding tostring
谁能告诉我如何修复类名的错误实例?
【问题讨论】:
标签: flutter dart overriding tostring
return placeName ?? '';
你只需要处理它是否为空
【讨论】:
输入字符串?意味着它必须在这种类型的变量中有一个字符串或 null 所以解决方案是将类型更改为 String 并将 required 关键字添加到构造函数中的命名参数。 试试这个可能有用...
【讨论】:
//'A value of type 'String?' can't be returned from the method 'toString' because it has a return type of 'String'
显示这个是因为你必须在那里处理空异常。做placeNmae?
或
if (placeName != null) {
return placeName;
//2
} else {
codeExceptionsomething();
}
}
【讨论】: