feat: adding default constructor on SvgComponent (#1334)

* feat: adding default constructor on SvgComponent

* fixing flame version

* svg not final anymore

* pr suggestions
This commit is contained in:
Erick
2022-01-24 09:30:39 -03:00
committed by GitHub
parent 9bff96bf3a
commit 00619f8047
4 changed files with 43 additions and 12 deletions

View File

@ -7,18 +7,51 @@ import './svg.dart';
/// Wraps [Svg] in a Flame component.
class SvgComponent extends PositionComponent {
/// The wrapped instance of [Svg].
Svg svg;
Svg? svg;
/// Creates an [SvgComponent] from an [Svg] instance.
SvgComponent.fromSvg(
this.svg, {
/// Creates an [SvgComponent]
SvgComponent({
this.svg,
Vector2? position,
Vector2? size,
Vector2? scale,
double? angle,
Anchor? anchor,
int? priority,
}) : super(position: position, size: size, priority: priority);
}) : super(
position: position,
size: size,
scale: scale,
angle: angle,
anchor: anchor,
priority: priority,
);
/// Creates an [SvgComponent] from an [Svg] instance.
@Deprecated(
'Will be removed on future versions, use the default '
'constructor instead',
)
SvgComponent.fromSvg(
Svg svg, {
Vector2? position,
Vector2? size,
Vector2? scale,
double? angle,
Anchor? anchor,
int? priority,
}) : this(
svg: svg,
position: position,
size: size,
scale: scale,
angle: angle,
anchor: anchor,
priority: priority,
);
@override
void render(Canvas canvas) {
svg.render(canvas, size);
svg?.render(canvas, size);
}
}