cancel method
Cancels the current task.
Calling this method will cause the task to fail. Both the Future (onComplete)
and stream (streamEvents
) will trigger an error with a FirebaseException.
Implementation
@override
Future<bool> cancel() async {
try {
if (!_initialTaskCompleter.isCompleted) {
await _initialTaskCompleter.future;
}
Map<String, dynamic>? data = await MethodChannelFirebaseStorage.channel
.invokeMapMethod<String, dynamic>('Task#cancel', <String, dynamic>{
'handle': _handle,
});
bool success = data!['status'];
if (success) {
_snapshot = MethodChannelTaskSnapshot(storage, TaskState.canceled,
Map<String, dynamic>.from(data['snapshot']));
}
return success;
} catch (e, stack) {
return catchFuturePlatformException<bool>(e, stack);
}
}