getAsset method

Future<T> getAsset(
  1. AssetProvider assetProvider
)

Get an asset from the cache or load it.

Implementation

Future<T> getAsset(AssetProvider assetProvider) async {
  T? asset = _assets[assetProvider];
  if (asset != null) {
    if (asset.isAvailable) {
      return asset;
    } else {
      return await asset.onLoaded() as T;
    }
  }

  asset = makeAsset();

  _assets[assetProvider] = asset;
  asset.load(this, assetProvider);
  return asset.isAvailable ? asset : await asset.onLoaded() as T;
}