小编Muh*_*lal的帖子

无法从“fetchById”方法返回“Null”类型的值,因为它的返回类型为“Location”

static Location fetchById(int id) {
   List<Location> locations = Location.fetchAll();

   for (var i = 0; i < locations.length; i++) {
     if (locations[i].id == id) {
       return locations[i];
     }
   }
   
   return null;
}
Run Code Online (Sandbox Code Playgroud)

// 如果条件不成立,则返回 null 当我尝试返回 null 或 false 时,它​​会给出错误“无法从方法 'fetchById' 返回类型为 'Null' 的值,因为它的返回类型为 '地点'。

dart flutter

-1
推荐指数
1
解决办法
3974
查看次数

标签 统计

dart ×1

flutter ×1