SpriteAnimationGroupComponent<T> constructor
SpriteAnimationGroupComponent<T> ({
- Map<
T, SpriteAnimation> ? animations, - T? current,
- bool? autoResize,
- bool playing = true,
- Map<
T, bool> removeOnFinish = const {}, - bool autoResetTicker = true,
- Paint? paint,
- Vector2? position,
- Vector2? size,
- Vector2? scale,
- double? angle,
- double nativeAngle = 0,
- Anchor? anchor,
- Iterable<
Component> ? children, - int? priority,
- ComponentKey? key,
Creates a component with an empty animation which can be set later
Implementation
SpriteAnimationGroupComponent({
Map<T, SpriteAnimation>? animations,
T? current,
bool? autoResize,
this.playing = true,
this.removeOnFinish = const {},
this.autoResetTicker = true,
Paint? paint,
super.position,
super.size,
super.scale,
super.angle,
super.nativeAngle,
super.anchor,
super.children,
super.priority,
super.key,
}) : assert(
(size == null) == (autoResize ?? size == null),
'''If size is set, autoResize should be false or size should be null when autoResize is true.''',
),
_current = current,
_animations = animations,
_autoResize = autoResize ?? size == null,
_animationTickers = animations != null
? Map.fromEntries(
animations.entries
.map((e) => MapEntry(e.key, e.value.createTicker()))
.toList(),
)
: null {
if (paint != null) {
this.paint = paint;
}
/// Register a listener to differentiate between size modification done by
/// external calls v/s the ones done by [_resizeToSprite].
size.addListener(_handleAutoResizeState);
_resizeToSprite();
}