load static method

Future<SpriteAnimation> load(
  1. String src,
  2. SpriteAnimationData data, {
  3. Images? images,
  4. String? package,
})

Takes the full path of an image, a SpriteAnimationData and loads the sprite animation.

The src is the full path of the asset, as declared in the pubspec.yaml, for example assets/images/player.png. When the images is omitted, the global Flame.images is used.

Implementation

static Future<SpriteAnimation> load(
  String src,
  SpriteAnimationData data, {
  Images? images,
  String? package,
}) async {
  final imagesCache = images ?? Flame.images;
  final image = await imagesCache.load(src, package: package);
  return SpriteAnimation.fromFrameData(image, data);
}