cancelRequest method

  1. @override
Future<bool?> cancelRequest(
  1. String requestId
)
override

Cancels a task by ID

requestId - task ID to cancel

Returns true if the task was cancelled, false if it could not be cancelled, null if the task does not exist

Implementation

@override
Future<bool?> cancelRequest(String requestId) async {
  try {
    final result = await methodChannel.invokeMethod<bool>(
      'cancelRequest',
      {'requestId': requestId},
    );
    return result;
  } on PlatformException catch (e) {
    // If the task is not found, return null
    if (e.code == 'NOT_FOUND') {
      return null;
    }
    rethrow;
  }
}