I'm using fpdart for catching errors in my flutter app. I wanted to get error message or success message directly without folding the whole response. There is getRight() and getLeft() method on res object but it returns Option<Success Data Type>
and Option<Error Data Type>
respectively. How could i extract the data directly without folding?
Future<Either<String, int>> getData() async {
try {
int data = await Future.delayed(Duration(seconds: 3), () => 15);
return right(data);
} catch (err) {
return left(err.toString());
}
}