SpriteGroupComponent<T> constructor
SpriteGroupComponent<T> ({})
Creates a component with an empty animation which can be set later.
Implementation
SpriteGroupComponent({
Map<T, Sprite>? sprites,
T? current,
bool? autoResize,
Paint? paint,
super.position,
Vector2? 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,
_sprites = sprites,
_autoResize = autoResize ?? size == null,
super(size: size ?? sprites?[current]?.srcSize) {
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].
this.size.addListener(_handleAutoResizeState);
}