tryGet abstract method
Attempts to retrieve the asset safely.
- If the asset exists, it is returned.
- If the asset does not exist, returns
null
instead of throwing, unlessorElseThrow
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]);