fromAsset static method

Future<Texture2D> fromAsset(
  1. String assetPath, {
  2. TextureContent content = TextureContent.color,
  3. TextureSampling sampling = const TextureSampling(),
  4. AssetBundle? bundle,
})

Loads, decodes, and uploads the image asset at assetPath.

Implementation

static Future<Texture2D> fromAsset(
  String assetPath, {
  TextureContent content = TextureContent.color,
  TextureSampling sampling = const TextureSampling(),
  AssetBundle? bundle,
}) async {
  final image = await imageFromAsset(assetPath, bundle: bundle);
  try {
    return await fromImage(image, content: content, sampling: sampling);
  } finally {
    image.dispose();
  }
}