tryGet abstract method

Asset? tryGet([
  1. Supplier<Exception>? orElseThrow
])

Attempts to retrieve the asset safely.

  • If the asset exists, it is returned.
  • If the asset does not exist, returns null instead of throwing, unless orElseThrow is provided, in which case the supplied exception will be thrown.

Example

final asset = resource.tryGet();
if (asset != null) {
  print("Asset loaded successfully");
} else {
  print("Asset not found");
}

Implementation

Asset? tryGet([Supplier<Exception>? orElseThrow]);