isSuccessful property

bool get isSuccessful

true if the status code is >= 200 && < 300 and nothing set an error.

The error clause matters when an interceptor throws while resolving an otherwise-2xx response: the body was never produced, so reporting success would hand the caller a null body.

Implementation

bool get isSuccessful =>
    statusCode >= 200 && statusCode < 300 && error == null;