diff --git a/packages/flame_svg/example/lib/main.dart b/packages/flame_svg/example/lib/main.dart index 9ca862034..e9f938b6b 100644 --- a/packages/flame_svg/example/lib/main.dart +++ b/packages/flame_svg/example/lib/main.dart @@ -19,8 +19,8 @@ class MyGame extends FlameGame { Future onLoad() async { await super.onLoad(); svgInstance = await loadSvg('android.svg'); - final android = SvgComponent.fromSvg( - svgInstance, + final android = SvgComponent( + svg: svgInstance, position: Vector2.all(100), size: Vector2.all(100), ); diff --git a/packages/flame_svg/example/pubspec.yaml b/packages/flame_svg/example/pubspec.yaml index 3e73a3e14..45b9beb19 100644 --- a/packages/flame_svg/example/pubspec.yaml +++ b/packages/flame_svg/example/pubspec.yaml @@ -11,8 +11,7 @@ environment: dependencies: flutter: sdk: flutter - flame: - path: ../../flame + flame: ^1.0.0 flame_svg: path: ../ diff --git a/packages/flame_svg/lib/svg_component.dart b/packages/flame_svg/lib/svg_component.dart index 7abda277e..8413cee91 100644 --- a/packages/flame_svg/lib/svg_component.dart +++ b/packages/flame_svg/lib/svg_component.dart @@ -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); } } diff --git a/packages/flame_svg/pubspec.yaml b/packages/flame_svg/pubspec.yaml index 91c5374c4..66af3cf7a 100644 --- a/packages/flame_svg/pubspec.yaml +++ b/packages/flame_svg/pubspec.yaml @@ -9,8 +9,7 @@ environment: flutter: ">=2.5.0" dependencies: - flame: - path: ../flame + flame: ^1.0.0 flutter_svg: ^0.22.0 flutter: sdk: flutter