fromAsset static method

Future<SkeletonData> fromAsset(
  1. Atlas atlas,
  2. String skeletonFile, {
  3. AssetBundle? bundle,
})

Loads a SkeletonData from the file skeletonFile in the root bundle or the optionally provided bundle. Uses the provided atlas to resolve attachment images.

Throws an Exception in case the skeleton data could not be loaded.

Implementation

static Future<SkeletonData> fromAsset(Atlas atlas, String skeletonFile, {AssetBundle? bundle}) async {
  bundle ??= rootBundle;
  if (skeletonFile.endsWith(".json")) {
    return fromJson(atlas, await bundle.loadString(skeletonFile));
  } else {
    return fromBinary(atlas, (await bundle.load(skeletonFile)).buffer.asUint8List());
  }
}