getSizeAsync static method

Future<Size> getSizeAsync(
  1. AsyncImageInput input
)

Get the size of the input.

If the input not exists, it will throw StateError.

If the input is not a valid image format, it will throw UnsupportedError.

The method is async.

Implementation

static Future<Size> getSizeAsync(AsyncImageInput input) async {
  if (!await input.exists()) {
    throw StateError('The input is not exists.');
  }

  if (!(await input.supportRangeLoad())) {
    final delegateInput = await input.delegateInput();
    try {
      return ImageSizeGetter.getSize(delegateInput);
    } finally {
      delegateInput.release();
    }
  }

  for (var value in _decoders) {
    if (await value.isValidAsync(input)) {
      return value.getSizeAsync(input);
    }
  }

  throw UnsupportedError('The input is not supported.');
}