尽管我已尝试应用我在 SO 上看到的大多数建议更改,但到目前为止没有任何效果。我在这里遇到了这个常见的例外-roleRaw!.map((roleJson) => RoleModel.fromJson(roleJson)).toList();
这是代码
class RoleRepository {
final RoleService roleService;
RoleRepository({required this.roleService});
Future<List<RoleModel>> fetchRoles() async {
final roleRaw = await roleService.fetchRoles();
final jSonConvert = roleRaw!.map((roleJson) => RoleModel.fromJson(roleJson)).toList();
return jSonConvert;
}
}
错误信息
[ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Null check operator used on a null value
E/flutter (20753): #0 RoleRepository.fetchRoles (package:etransfa/christdoes/bank/persistence/repository/role_repository.dart:11:35)
E/flutter (20753): <asynchronous suspension>
我能做些什么?