isTransientError function
Classifies whether an error is transient and worth retrying.
Implementation
bool isTransientError(Object error) {
if (error is SocketException) return true;
if (error is HttpException) return true;
if (error is TimeoutException) return true;
if (error is HttpDownloadException) return error.isTransient;
return false;
}