I moved my project to the sdk 2.12 and trying to update my code with the non-nullable crap.
Now I don't understand how to fix things in 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)
.
It says: The argument type 'Object' can't be assigned to the parameter type 'Exception*'.
How this should be fixed?
Have you tried using dartz: ^0.10.0-nullsafety.2
, which is the pre-release version for null safety. Please check for the latest version on pub.dev.