result method
Executes onSuccess if the future completes successfully,
and onError if it fails.
Implementation
Future<T> result({
void Function(T data)? onSuccess,
void Function(Object error)? onError,
}) async {
try {
final data = await this;
onSuccess?.call(data);
return data;
} catch (e) {
onError?.call(e);
rethrow;
}
}