cancelableFuture method
Wrap cancelable async process with connection status -
needCheckConnection
and error process if need - needHandleError
.
Implementation
@protected
Future? cancelableFuture(
Future inner, {
String? tag,
bool needCheckConnection = true,
bool needHandleError = true,
}) async {
final preProcess =
needCheckConnection ? () async => checkConnection() : null;
final process = _processCancelableFuture(inner, preProcess: preProcess);
return needHandleError
? process?.onError(
(error, stackTrace) {
if (error is Exception) {
handleError(error, tag: tag);
}
},
)
: process;
}