【问题标题】:How can I fix the error instance of class name?如何修复类名的错误实例?
【发布时间】:2022-01-02 11:25:29
【问题描述】:

谁能告诉我如何修复类名的错误实例?

【问题讨论】:

    标签: flutter dart overriding tostring


    【解决方案1】:
    return placeName ?? '';
    

    你只需要处理它是否为空

    【讨论】:

      【解决方案2】:

      输入字符串?意味着它必须在这种类型的变量中有一个字符串或 null 所以解决方案是将类型更改为 String 并将 required 关键字添加到构造函数中的命名参数。 试试这个可能有用...

      【讨论】:

        【解决方案3】:
        //'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();
          }
        }
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-03-18
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-04-04
          相关资源
          最近更新 更多