[英]Fix Dartz package with non nullable
I moved my project to the sdk 2.12 and trying to update my code with the non-nullable crap.我将我的项目移至 sdk 2.12 并尝试使用不可为空的废话更新我的代码。
Now I don't understand how to fix things in Dartz package...现在我不明白如何修复 Dartz package 中的问题......
Example:例子:
import 'package:dartz/dartz.dart';
import 'package:mobile_100asa/http.dart';
class StatusApi {
String endpoint = 'https://myApi.net';
Future<Either<Exception, String>?> getStatus() async { // Forced to make nullable response here
try {
var response = await dio.get('$endpoint/test');
return Right(response);
} catch (error) {
print(error);
return (Left(error)); // Error Here
}
}
}
I'm forced to make a nullable response and then I don't know what is wrong with the catch(error)
.我被迫做出可以为空的响应,然后我不知道
catch(error)
有什么问题。
It says: The argument type 'Object' can't be assigned to the parameter type 'Exception*'.它说:参数类型“对象”不能分配给参数类型“异常*”。
How this should be fixed?这应该如何解决?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.