existsAsync method

Future<bool> existsAsync()

Asks the server whether the resource is there: a HEAD request (a GET when the server rejects HEAD) answered below 400, like Spring's exists(). A 404 or a connection error means it does not exist. Always true on the web, where reading then fails.

if (await resource.existsAsync()) {
  final text = await resource.readAsString();
}

Implementation

Future<bool> existsAsync() => FileAccess.urlExists(url);