get method

  1. @override
Asset get([
  1. Supplier<Exception>? throwIfNotFound
])
override

Retrieves the asset represented by this resource.

  • If the asset does not exist and throwIfNotFound is provided, the supplied exception will be thrown.
  • If throwIfNotFound is not provided, a generic exception may be thrown.

Example

try {
  final asset = resource.get(() => Exception("Missing resource"));
  print("Loaded: $asset");
} catch (e) {
  print("Failed to load asset: $e");
}

Implementation

@override
Asset get([Supplier<Exception>? throwIfNotFound]) {
  if(_asset != null) {
    return _asset!;
  } else if(throwIfNotFound != null) {
    throw throwIfNotFound();
  } else {
    throw _throwIfNotFound();
  }
}