【问题标题】:Error: Method 'toUpperCase' cannot be called on 'String?' because it is potentially null错误:无法在 \'String?\' 上调用方法 \'toUpperCase\',因为它可能为 null
【发布时间】:2022-11-12 01:35:32
【问题描述】:

我应该修理什么?这是错误。

characterList[index]['real_name'].toUpperCase()

如何修复错误?

【问题讨论】:

    标签: dart


    【解决方案1】:

    像这样添加空检查

    characterList[index]['real_name']!.toUpperCase()
    

    或更改字符串?到字符串

    【讨论】:

      猜你喜欢
      • 2022-06-25
      • 2021-12-30
      • 2021-08-06
      • 1970-01-01
      • 1970-01-01
      • 2021-08-10
      • 2022-10-13
      • 1970-01-01
      • 2021-09-05
      相关资源
      最近更新 更多