reload method

  1. @override
Sprite<int> reload()
override

Re-resolves this sprite against Ignis.cache.

Returns this unless what it was built from has since been replaced, so the caller can tell whether anything changed by identity.

Implementation

@override
Sprite<int> reload() {
  // Art evicted rather than replaced keeps whatever it last cut.
  if (!region.isLoaded) return this;
  final entry = entries.single;
  if (identical(region.image, entry.image)) return this;

  // A replacement image this region no longer fits keeps the last cut.
  if (!region.fits) return this;

  return SpriteAnimation._(
    region,
    List.generate(
      region.frames,
      (frame) => entry.duration(frame < entry.frames ? frame : entry.frames - 1),
      growable: false,
    ),
    entry.loops,
  );
}