From c542d3c34bf911cec8332dcdeb65d0017e6cb576 Mon Sep 17 00:00:00 2001 From: Erick Date: Wed, 2 Aug 2023 09:30:43 -0300 Subject: [PATCH] feat: Adding key argument to shape components (#2632) Components based on `ShapeComponent` were missing the `key` constructor argument. This PR addresses that. --- packages/flame/lib/src/geometry/polygon_component.dart | 3 +++ packages/flame/lib/src/geometry/rectangle_component.dart | 5 +++++ packages/flame/lib/src/geometry/shape_component.dart | 1 + 3 files changed, 9 insertions(+) diff --git a/packages/flame/lib/src/geometry/polygon_component.dart b/packages/flame/lib/src/geometry/polygon_component.dart index 521f94fa2da..8b18927923a 100644 --- a/packages/flame/lib/src/geometry/polygon_component.dart +++ b/packages/flame/lib/src/geometry/polygon_component.dart @@ -38,6 +38,7 @@ class PolygonComponent extends ShapeComponent { super.priority, super.paint, super.paintLayers, + super.key, bool? shrinkToBounds, }) : assert( _vertices.length > 2, @@ -78,6 +79,7 @@ class PolygonComponent extends ShapeComponent { Paint? paint, List? paintLayers, bool? shrinkToBounds, + ComponentKey? key, }) : this( normalsToVertices(relation, parentSize), position: position, @@ -88,6 +90,7 @@ class PolygonComponent extends ShapeComponent { paint: paint, paintLayers: paintLayers, shrinkToBounds: shrinkToBounds, + key: key, ); @internal diff --git a/packages/flame/lib/src/geometry/rectangle_component.dart b/packages/flame/lib/src/geometry/rectangle_component.dart index 1f176409cfa..2d3165e964c 100644 --- a/packages/flame/lib/src/geometry/rectangle_component.dart +++ b/packages/flame/lib/src/geometry/rectangle_component.dart @@ -14,6 +14,7 @@ class RectangleComponent extends PolygonComponent { super.priority, super.paint, super.paintLayers, + super.key, }) : super(sizeToVertices(size ?? Vector2.zero(), anchor)) { size.addListener( () => refreshVertices( @@ -32,6 +33,7 @@ class RectangleComponent extends PolygonComponent { super.paint, super.paintLayers, super.children, + super.key, }) : super(sizeToVertices(Vector2.all(size), anchor)) { this.size.addListener( () => refreshVertices( @@ -56,6 +58,7 @@ class RectangleComponent extends PolygonComponent { super.paint, super.paintLayers, super.shrinkToBounds, + super.key, }) : super.relative([ relation.clone(), Vector2(relation.x, -relation.y), @@ -78,6 +81,7 @@ class RectangleComponent extends PolygonComponent { int? priority, Paint? paint, List? paintLayers, + ComponentKey? key, }) { return RectangleComponent( position: anchor == Anchor.topLeft @@ -93,6 +97,7 @@ class RectangleComponent extends PolygonComponent { priority: priority, paint: paint, paintLayers: paintLayers, + key: key, ); } diff --git a/packages/flame/lib/src/geometry/shape_component.dart b/packages/flame/lib/src/geometry/shape_component.dart index 28ac86408d7..63ddb91ebed 100644 --- a/packages/flame/lib/src/geometry/shape_component.dart +++ b/packages/flame/lib/src/geometry/shape_component.dart @@ -15,6 +15,7 @@ abstract class ShapeComponent extends PositionComponent with HasPaint { super.anchor, super.children, super.priority, + super.key, Paint? paint, List? paintLayers, }) {