There is no guarantee that Task.CancellationError will be thrown when a task is cancelled -- the returned error depends on which subsystem notices the cancellation, which will throw whatever error is relevant to having its execution cancelled. Task.CancellationError is only guaranteed to be thrown by Task.checkCancellation() if invoked, or can be used as a convenience type when you don't want/need your own error type to handle cancellation.
A 100% reliable way to check if a task has been canceled is to check if Task.isCancelled is true.
You can also do this in your catch handler. Keep in mind that this still won't tell you whether the called function threw an error because it was canceled or for some other failure that occurred at the same time, but that distinction is probably not important in most cases.
If you know the concrete error an API throws on cancellation (as in your case), it's a good idea to check for it specifically.
For general purpose code where you don't know the specific error, I'd check for CancellationError and also for Task.isCancelled to cover all the APIs that don't throw a CancellationError.