mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-10-31 17:06:50 +08:00 
			
		
		
		
	feat: Move to Flutter 3.0.0 and Dart 2.17.0 (#1713)
This upgrades all packages to Flutter 3.0.0 and fixes all analyze issues that came from that.
This commit is contained in:
		| @ -4,8 +4,8 @@ version: 1.0.0 | ||||
| publish_to: none | ||||
|  | ||||
| environment: | ||||
|   sdk: ^2.16.0 | ||||
|   flutter: ^2.10.0 | ||||
|   sdk: ">=2.17.0 <3.0.0" | ||||
|   flutter: ^3.0.0 | ||||
|  | ||||
| dependencies: | ||||
|   flame: ^1.2.0 | ||||
|  | ||||
| @ -4,7 +4,7 @@ version: 1.0.0 | ||||
| publish_to: none | ||||
|  | ||||
| environment: | ||||
|   sdk: ^2.15.0 | ||||
|   sdk: ^2.17.0 | ||||
|  | ||||
| dependencies: | ||||
|   flame: ^1.2.0 | ||||
|  | ||||
| @ -3,7 +3,7 @@ import 'package:padracing/menu_card.dart'; | ||||
| import 'package:padracing/padracing_game.dart'; | ||||
|  | ||||
| class GameOver extends StatelessWidget { | ||||
|   const GameOver(this.game, {Key? key}) : super(key: key); | ||||
|   const GameOver(this.game, {super.key}); | ||||
|  | ||||
|   final PadRacingGame game; | ||||
|  | ||||
|  | ||||
| @ -6,7 +6,7 @@ import 'package:padracing/padracing_game.dart'; | ||||
| import 'package:url_launcher/url_launcher.dart'; | ||||
|  | ||||
| class Menu extends StatelessWidget { | ||||
|   const Menu(this.game, {Key? key}) : super(key: key); | ||||
|   const Menu(this.game, {super.key}); | ||||
|  | ||||
|   final PadRacingGame game; | ||||
|  | ||||
|  | ||||
| @ -3,7 +3,7 @@ import 'package:flutter/material.dart' hide Image, Gradient; | ||||
| import 'package:padracing/game_colors.dart'; | ||||
|  | ||||
| class MenuCard extends StatelessWidget { | ||||
|   const MenuCard({Key? key, required this.children}) : super(key: key); | ||||
|   const MenuCard({super.key, required this.children}); | ||||
|  | ||||
|   final List<Widget> children; | ||||
|  | ||||
|  | ||||
| @ -7,7 +7,7 @@ import 'package:padracing/menu.dart'; | ||||
| import 'package:padracing/padracing_game.dart'; | ||||
|  | ||||
| class PadracingWidget extends StatelessWidget { | ||||
|   const PadracingWidget({Key? key}) : super(key: key); | ||||
|   const PadracingWidget({super.key}); | ||||
|  | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|  | ||||
| @ -4,7 +4,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev | ||||
| version: 1.0.0+1 | ||||
|  | ||||
| environment: | ||||
|   sdk: ">=2.16.0 <3.0.0" | ||||
|   sdk: ">=2.17.0 <3.0.0" | ||||
|  | ||||
| dependencies: | ||||
|   flame: ^1.2.0 | ||||
|  | ||||
| @ -3,7 +3,7 @@ import 'package:flutter/material.dart' hide Image, Gradient; | ||||
| import 'package:trex_game/trex_game.dart'; | ||||
|  | ||||
| class TRexWidget extends StatelessWidget { | ||||
|   const TRexWidget({Key? key}) : super(key: key); | ||||
|   const TRexWidget({super.key}); | ||||
|  | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|  | ||||
| @ -6,8 +6,8 @@ publish_to: 'none' | ||||
| version: 0.1.0 | ||||
|  | ||||
| environment: | ||||
|   sdk: ">=2.16.0 <3.0.0" | ||||
|   flutter: ">=2.10.0" | ||||
|   sdk: ">=2.17.0 <3.0.0" | ||||
|   flutter: ^3.0.0 | ||||
|  | ||||
| dependencies: | ||||
|   flame: ^1.2.0 | ||||
|  | ||||
| @ -4,11 +4,9 @@ import 'package:meta/meta.dart'; | ||||
|  | ||||
| class Ember<T extends FlameGame> extends SpriteAnimationComponent | ||||
|     with HasGameRef<T> { | ||||
|   Ember({Vector2? position, Vector2? size, int? priority}) | ||||
|   Ember({super.position, Vector2? size, super.priority}) | ||||
|       : super( | ||||
|           position: position, | ||||
|           size: size ?? Vector2.all(50), | ||||
|           priority: priority, | ||||
|           anchor: Anchor.center, | ||||
|         ); | ||||
|  | ||||
|  | ||||
| @ -69,7 +69,7 @@ class TappableBall extends Ball with Tappable { | ||||
|   int counter = 0; | ||||
|   late final TextPaint _textPaint; | ||||
|  | ||||
|   TappableBall(Vector2 position) : super(position) { | ||||
|   TappableBall(super.position) { | ||||
|     originalPaint = Paint()..color = Colors.amber; | ||||
|     paint = originalPaint; | ||||
|   } | ||||
|  | ||||
| @ -25,7 +25,7 @@ class DraggableExample extends Forge2DGame with HasDraggables { | ||||
| } | ||||
|  | ||||
| class DraggableBall extends Ball with Draggable { | ||||
|   DraggableBall(Vector2 position) : super(position, radius: 5) { | ||||
|   DraggableBall(super.position) : super(radius: 5) { | ||||
|     originalPaint = Paint()..color = Colors.amber; | ||||
|     paint = originalPaint; | ||||
|   } | ||||
|  | ||||
| @ -24,7 +24,7 @@ class TappableExample extends Forge2DGame with HasTappables { | ||||
| } | ||||
|  | ||||
| class TappableBall extends Ball with Tappable { | ||||
|   TappableBall(Vector2 position) : super(position) { | ||||
|   TappableBall(super.position) { | ||||
|     originalPaint = BasicPalette.white.paint(); | ||||
|     paint = originalPaint; | ||||
|   } | ||||
|  | ||||
| @ -83,7 +83,7 @@ class Ball extends BodyComponent with ContactCallbacks { | ||||
| } | ||||
|  | ||||
| class WhiteBall extends Ball with ContactCallbacks { | ||||
|   WhiteBall(Vector2 position) : super(position) { | ||||
|   WhiteBall(super.position) { | ||||
|     originalPaint = BasicPalette.white.paint(); | ||||
|     paint = originalPaint; | ||||
|   } | ||||
|  | ||||
| @ -61,7 +61,7 @@ class WidgetExample extends Forge2DGame with TapDetector { | ||||
| } | ||||
|  | ||||
| class BodyWidgetExample extends StatelessWidget { | ||||
|   const BodyWidgetExample({Key? key}) : super(key: key); | ||||
|   const BodyWidgetExample({super.key}); | ||||
|  | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
| @ -87,8 +87,8 @@ class BodyButtonWidget extends StatefulWidget { | ||||
|   const BodyButtonWidget( | ||||
|     this._game, | ||||
|     this._bodyId, { | ||||
|     Key? key, | ||||
|   }) : super(key: key); | ||||
|     super.key, | ||||
|   }); | ||||
|  | ||||
|   @override | ||||
|   State<StatefulWidget> createState() { | ||||
|  | ||||
| @ -164,7 +164,7 @@ class CoordinateSystemsExample extends FlameGame | ||||
| /// on each direction (top, bottom, left and right) and allow adding | ||||
| /// or removing containers. | ||||
| class CoordinateSystemsWidget extends StatefulWidget { | ||||
|   const CoordinateSystemsWidget({Key? key}) : super(key: key); | ||||
|   const CoordinateSystemsWidget({super.key}); | ||||
|  | ||||
|   @override | ||||
|   State<StatefulWidget> createState() { | ||||
|  | ||||
| @ -186,11 +186,11 @@ class CollidablePolygon extends MyCollidable { | ||||
|  | ||||
| class CollidableRectangle extends MyCollidable { | ||||
|   CollidableRectangle( | ||||
|     Vector2 position, | ||||
|     Vector2 size, | ||||
|     Vector2 velocity, | ||||
|     ScreenHitbox screenHitbox, | ||||
|   ) : super(position, size, velocity, screenHitbox) { | ||||
|     super.position, | ||||
|     super.size, | ||||
|     super.velocity, | ||||
|     super.screenHitbox, | ||||
|   ) { | ||||
|     hitbox = RectangleHitbox()..renderShape = true; | ||||
|     add(hitbox!); | ||||
|   } | ||||
| @ -198,11 +198,11 @@ class CollidableRectangle extends MyCollidable { | ||||
|  | ||||
| class CollidableCircle extends MyCollidable { | ||||
|   CollidableCircle( | ||||
|     Vector2 position, | ||||
|     Vector2 size, | ||||
|     Vector2 velocity, | ||||
|     ScreenHitbox screenHitbox, | ||||
|   ) : super(position, size, velocity, screenHitbox) { | ||||
|     super.position, | ||||
|     super.size, | ||||
|     super.velocity, | ||||
|     super.screenHitbox, | ||||
|   ) { | ||||
|     hitbox = CircleHitbox()..renderShape = true; | ||||
|     add(hitbox!); | ||||
|   } | ||||
|  | ||||
| @ -24,8 +24,8 @@ class RemoveEffectExample extends FlameGame with HasTappables { | ||||
| } | ||||
|  | ||||
| class _RandomCircle extends CircleComponent with Tappable { | ||||
|   _RandomCircle(double radius, {Vector2? position, Paint? paint}) | ||||
|       : super(radius: radius, position: position, paint: paint); | ||||
|   _RandomCircle(double radius, {super.position, super.paint}) | ||||
|       : super(radius: radius); | ||||
|  | ||||
|   factory _RandomCircle.random(Random rng) { | ||||
|     final radius = rng.nextDouble() * 30 + 10; | ||||
|  | ||||
| @ -66,13 +66,10 @@ class MyShapeComponent extends PositionComponent | ||||
|  | ||||
|   MyShapeComponent({ | ||||
|     required this.hitbox, | ||||
|     Vector2? position, | ||||
|     Vector2? size, | ||||
|     double? angle, | ||||
|     super.position, | ||||
|     super.size, | ||||
|     super.angle, | ||||
|   }) : super( | ||||
|           position: position, | ||||
|           size: size, | ||||
|           angle: angle, | ||||
|           anchor: Anchor.center, | ||||
|         ); | ||||
|  | ||||
|  | ||||
| @ -78,15 +78,13 @@ final _shaded = TextPaint( | ||||
| class MyTextBox extends TextBoxComponent { | ||||
|   MyTextBox( | ||||
|     String text, { | ||||
|     Anchor? align, | ||||
|     Vector2? size, | ||||
|     super.align, | ||||
|     super.size, | ||||
|     double? timePerChar, | ||||
|     double? margins, | ||||
|   }) : super( | ||||
|           text: text, | ||||
|           textRenderer: _box, | ||||
|           align: align, | ||||
|           size: size, | ||||
|           boxConfig: TextBoxConfig( | ||||
|             maxWidth: 400, | ||||
|             timePerChar: timePerChar ?? 0.05, | ||||
|  | ||||
| @ -6,8 +6,8 @@ publish_to: 'none' | ||||
| version: 0.1.0 | ||||
|  | ||||
| environment: | ||||
|   sdk: ">=2.16.0 <3.0.0" | ||||
|   flutter: ">=2.10.0" | ||||
|   sdk: ">=2.17.0 <3.0.0" | ||||
|   flutter: ^3.0.0 | ||||
|  | ||||
| dependencies: | ||||
|   dashbook: 0.1.6 | ||||
|  | ||||
| @ -4,8 +4,8 @@ version: 0.1.0 | ||||
| publish_to: 'none' | ||||
|  | ||||
| environment: | ||||
|   sdk: ">=2.16.0 <3.0.0" | ||||
|   flutter: ">=2.10.0" | ||||
|   sdk: ">=2.17.0 <3.0.0" | ||||
|   flutter: ^3.0.0 | ||||
|  | ||||
| dependencies: | ||||
|   flame: ^1.2.0 | ||||
|  | ||||
| @ -76,9 +76,9 @@ class _Asset<T> { | ||||
| } | ||||
|  | ||||
| class _StringAsset extends _Asset<String> { | ||||
|   _StringAsset(String value) : super(value); | ||||
|   _StringAsset(super.value); | ||||
| } | ||||
|  | ||||
| class _BinaryAsset extends _Asset<List<int>> { | ||||
|   _BinaryAsset(List<int> value) : super(value); | ||||
|   _BinaryAsset(super.value); | ||||
| } | ||||
|  | ||||
| @ -1,3 +1,5 @@ | ||||
| // ignore_for_file: comment_references | ||||
|  | ||||
| import 'package:flame/collisions.dart'; | ||||
| import 'package:flame/components.dart'; | ||||
|  | ||||
| @ -7,35 +9,23 @@ class CircleHitbox extends CircleComponent with ShapeHitbox { | ||||
|   final bool shouldFillParent; | ||||
|  | ||||
|   CircleHitbox({ | ||||
|     double? radius, | ||||
|     Vector2? position, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|   })  : shouldFillParent = radius == null && position == null, | ||||
|         super( | ||||
|           radius: radius, | ||||
|           position: position, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|         ); | ||||
|     super.radius, | ||||
|     super.position, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|   }) : shouldFillParent = radius == null && position == null; | ||||
|  | ||||
|   /// With this constructor you define the [CircleHitbox] in relation to the | ||||
|   /// [parentSize]. For example having a [relation] of 0.5 would create a circle | ||||
|   /// that fills half of the [parentSize]. | ||||
|   CircleHitbox.relative( | ||||
|     double relation, { | ||||
|     Vector2? position, | ||||
|     required Vector2 parentSize, | ||||
|     double angle = 0, | ||||
|     Anchor? anchor, | ||||
|     super.relation, { | ||||
|     super.position, | ||||
|     required super.parentSize, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|   })  : shouldFillParent = false, | ||||
|         super.relative( | ||||
|           relation, | ||||
|           position: position, | ||||
|           parentSize: parentSize, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|         ); | ||||
|         super.relative(); | ||||
|  | ||||
|   @override | ||||
|   void fillParent() { | ||||
|  | ||||
| @ -11,20 +11,12 @@ import 'package:flame/components.dart'; | ||||
| class CompositeHitbox extends PositionComponent | ||||
|     with CollisionCallbacks, CollisionPassthrough { | ||||
|   CompositeHitbox({ | ||||
|     Vector2? position, | ||||
|     Vector2? size, | ||||
|     Vector2? scale, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     Iterable<ShapeHitbox>? children, | ||||
|     int? priority, | ||||
|   }) : super( | ||||
|           position: position, | ||||
|           size: size, | ||||
|           scale: scale, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           children: children, | ||||
|           priority: priority, | ||||
|         ); | ||||
|     super.position, | ||||
|     super.size, | ||||
|     super.scale, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|     Iterable<ShapeHitbox>? super.children, | ||||
|     super.priority, | ||||
|   }); | ||||
| } | ||||
|  | ||||
| @ -1,17 +1,15 @@ | ||||
| // ignore_for_file: comment_references | ||||
|  | ||||
| import 'package:flame/collisions.dart'; | ||||
| import 'package:flame/components.dart'; | ||||
|  | ||||
| /// A [Hitbox] in the shape of a polygon. | ||||
| class PolygonHitbox extends PolygonComponent with ShapeHitbox { | ||||
|   PolygonHitbox( | ||||
|     List<Vector2> vertices, { | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|   }) : super( | ||||
|           vertices, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|         ); | ||||
|     super.vertices, { | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|   }); | ||||
|  | ||||
|   /// With this constructor you define the [PolygonHitbox] in relation to the | ||||
|   /// [parentSize] of the hitbox. | ||||
| @ -21,17 +19,12 @@ class PolygonHitbox extends PolygonComponent with ShapeHitbox { | ||||
|   /// NOTE: Always define your shape in a counter-clockwise fashion (in the | ||||
|   /// screen coordinate system) | ||||
|   PolygonHitbox.relative( | ||||
|     List<Vector2> relation, { | ||||
|     Vector2? position, | ||||
|     required Vector2 parentSize, | ||||
|     double angle = 0, | ||||
|     Anchor? anchor, | ||||
|     super.relation, { | ||||
|     super.position, | ||||
|     required super.parentSize, | ||||
|     double super.angle = 0, | ||||
|     super.anchor, | ||||
|   }) : super.relative( | ||||
|           relation, | ||||
|           position: position, | ||||
|           parentSize: parentSize, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           shrinkToBounds: true, | ||||
|         ); | ||||
|  | ||||
|  | ||||
| @ -1,3 +1,5 @@ | ||||
| // ignore_for_file: comment_references | ||||
|  | ||||
| import 'package:flame/collisions.dart'; | ||||
| import 'package:flame/components.dart'; | ||||
|  | ||||
| @ -7,37 +9,25 @@ class RectangleHitbox extends RectangleComponent with ShapeHitbox { | ||||
|   final bool shouldFillParent; | ||||
|  | ||||
|   RectangleHitbox({ | ||||
|     Vector2? position, | ||||
|     Vector2? size, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     int? priority, | ||||
|   })  : shouldFillParent = size == null && position == null, | ||||
|         super( | ||||
|           position: position, | ||||
|           size: size, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           priority: priority, | ||||
|         ); | ||||
|     super.position, | ||||
|     super.size, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|     super.priority, | ||||
|   }) : shouldFillParent = size == null && position == null; | ||||
|  | ||||
|   /// With this constructor you define the [RectangleHitbox] in relation to | ||||
|   /// the [parentSize]. For example having [relation] as of (0.8, 0.5) would | ||||
|   /// create a rectangle that fills 80% of the width and 50% of the height of | ||||
|   /// [parentSize]. | ||||
|   RectangleHitbox.relative( | ||||
|     Vector2 relation, { | ||||
|     Vector2? position, | ||||
|     required Vector2 parentSize, | ||||
|     double angle = 0, | ||||
|     Anchor? anchor, | ||||
|     super.relation, { | ||||
|     super.position, | ||||
|     required super.parentSize, | ||||
|     double super.angle, | ||||
|     super.anchor, | ||||
|   })  : shouldFillParent = false, | ||||
|         super.relative( | ||||
|           relation, | ||||
|           position: position, | ||||
|           parentSize: parentSize, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           shrinkToBounds: true, | ||||
|         ); | ||||
|  | ||||
|  | ||||
| @ -3,7 +3,7 @@ import 'package:flame/src/collisions/collision_callbacks.dart'; | ||||
| import 'package:flame/src/collisions/hitboxes/hitbox.dart'; | ||||
|  | ||||
| class Sweep<T extends Hitbox<T>> extends Broadphase<T> { | ||||
|   Sweep({List<T>? items}) : super(items: items); | ||||
|   Sweep({super.items}); | ||||
|  | ||||
|   final List<T> _active = []; | ||||
|   final Set<CollisionProspect<T>> _potentials = {}; | ||||
|  | ||||
| @ -16,22 +16,14 @@ class CustomPainterComponent extends PositionComponent { | ||||
|  | ||||
|   CustomPainterComponent({ | ||||
|     this.painter, | ||||
|     Vector2? position, | ||||
|     Vector2? size, | ||||
|     Vector2? scale, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     Iterable<Component>? children, | ||||
|     int? priority, | ||||
|   }) : super( | ||||
|           position: position, | ||||
|           size: size, | ||||
|           scale: scale, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           children: children, | ||||
|           priority: priority, | ||||
|         ); | ||||
|     super.position, | ||||
|     super.size, | ||||
|     super.scale, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|     super.children, | ||||
|     super.priority, | ||||
|   }); | ||||
|  | ||||
|   @override | ||||
|   @mustCallSuper | ||||
|  | ||||
| @ -7,21 +7,15 @@ class FpsTextComponent<T extends TextRenderer> extends TextComponent { | ||||
|   FpsTextComponent({ | ||||
|     int windowSize = 60, | ||||
|     this.decimalPlaces = 0, | ||||
|     T? textRenderer, | ||||
|     Vector2? position, | ||||
|     Vector2? size, | ||||
|     Vector2? scale, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     T? super.textRenderer, | ||||
|     super.position, | ||||
|     super.size, | ||||
|     super.scale, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|     int? priority, | ||||
|   })  : fpsComponent = FpsComponent(windowSize: windowSize), | ||||
|         super( | ||||
|           textRenderer: textRenderer, | ||||
|           position: position, | ||||
|           size: size, | ||||
|           scale: scale, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           priority: priority ?? double.maxFinite.toInt(), | ||||
|         ) { | ||||
|     positionType = PositionType.viewport; | ||||
|  | ||||
| @ -26,21 +26,15 @@ class ButtonComponent extends PositionComponent with Tappable { | ||||
|     this.buttonDown, | ||||
|     this.onPressed, | ||||
|     this.onReleased, | ||||
|     Vector2? position, | ||||
|     super.position, | ||||
|     Vector2? size, | ||||
|     Vector2? scale, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     Iterable<Component>? children, | ||||
|     int? priority, | ||||
|     super.scale, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|     super.children, | ||||
|     super.priority, | ||||
|   }) : super( | ||||
|           position: position, | ||||
|           size: size ?? button?.size, | ||||
|           scale: scale, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           children: children, | ||||
|           priority: priority, | ||||
|         ); | ||||
|  | ||||
|   @override | ||||
|  | ||||
| @ -10,30 +10,20 @@ import 'package:flutter/rendering.dart' show EdgeInsets; | ||||
| class HudButtonComponent extends ButtonComponent | ||||
|     with HasGameRef, ComponentViewportMargin { | ||||
|   HudButtonComponent({ | ||||
|     PositionComponent? button, | ||||
|     PositionComponent? buttonDown, | ||||
|     super.button, | ||||
|     super.buttonDown, | ||||
|     EdgeInsets? margin, | ||||
|     Function()? onPressed, | ||||
|     Function()? onReleased, | ||||
|     Vector2? position, | ||||
|     Function()? super.onPressed, | ||||
|     Function()? super.onReleased, | ||||
|     super.position, | ||||
|     Vector2? size, | ||||
|     Vector2? scale, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     Iterable<Component>? children, | ||||
|     int? priority, | ||||
|     super.scale, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|     super.children, | ||||
|     super.priority, | ||||
|   }) : super( | ||||
|           button: button, | ||||
|           buttonDown: buttonDown, | ||||
|           position: position, | ||||
|           onPressed: onPressed, | ||||
|           onReleased: onReleased, | ||||
|           size: size ?? button?.size, | ||||
|           scale: scale, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           children: children, | ||||
|           priority: priority, | ||||
|         ) { | ||||
|     this.margin = margin; | ||||
|   } | ||||
|  | ||||
| @ -24,25 +24,16 @@ class HudMarginComponent<T extends FlameGame> extends PositionComponent | ||||
|  | ||||
|   HudMarginComponent({ | ||||
|     this.margin, | ||||
|     Vector2? position, | ||||
|     Vector2? size, | ||||
|     Vector2? scale, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     Iterable<Component>? children, | ||||
|     int? priority, | ||||
|     super.position, | ||||
|     super.size, | ||||
|     super.scale, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|     super.children, | ||||
|     super.priority, | ||||
|   }) : assert( | ||||
|           margin != null || position != null, | ||||
|           'Either margin or position must be defined', | ||||
|         ), | ||||
|         super( | ||||
|           position: position, | ||||
|           size: size, | ||||
|           scale: scale, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           children: children, | ||||
|           priority: priority, | ||||
|         ); | ||||
|  | ||||
|   @override | ||||
|  | ||||
| @ -3,7 +3,6 @@ import 'dart:math'; | ||||
| import 'package:flame/components.dart'; | ||||
| import 'package:flame/src/components/input/hud_margin_component.dart'; | ||||
| import 'package:flame/src/gestures/events.dart'; | ||||
| import 'package:flutter/rendering.dart' show EdgeInsets; | ||||
| import 'package:meta/meta.dart'; | ||||
|  | ||||
| enum JoystickDirection { | ||||
| @ -47,13 +46,13 @@ class JoystickComponent extends HudMarginComponent with Draggable { | ||||
|   JoystickComponent({ | ||||
|     this.knob, | ||||
|     this.background, | ||||
|     EdgeInsets? margin, | ||||
|     Vector2? position, | ||||
|     super.margin, | ||||
|     super.position, | ||||
|     double? size, | ||||
|     double? knobRadius, | ||||
|     Anchor anchor = Anchor.center, | ||||
|     Iterable<Component>? children, | ||||
|     int? priority, | ||||
|     Anchor super.anchor = Anchor.center, | ||||
|     super.children, | ||||
|     super.priority, | ||||
|   })  : assert( | ||||
|           size != null || background != null, | ||||
|           'Either size or background must be defined', | ||||
| @ -64,12 +63,7 @@ class JoystickComponent extends HudMarginComponent with Draggable { | ||||
|           'Positions should not be set for the knob or the background', | ||||
|         ), | ||||
|         super( | ||||
|           margin: margin, | ||||
|           position: position, | ||||
|           size: background?.size ?? Vector2.all(size ?? 0), | ||||
|           anchor: anchor, | ||||
|           children: children, | ||||
|           priority: priority, | ||||
|         ) { | ||||
|     this.knobRadius = knobRadius ?? this.size.x / 2; | ||||
|   } | ||||
|  | ||||
| @ -22,22 +22,16 @@ class SpriteButtonComponent extends SpriteGroupComponent<_ButtonState> | ||||
|     this.button, | ||||
|     this.buttonDown, | ||||
|     this.onPressed, | ||||
|     Vector2? position, | ||||
|     super.position, | ||||
|     Vector2? size, | ||||
|     Vector2? scale, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     Iterable<Component>? children, | ||||
|     int? priority, | ||||
|     super.scale, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|     super.children, | ||||
|     super.priority, | ||||
|   }) : super( | ||||
|           current: _ButtonState.up, | ||||
|           position: position, | ||||
|           size: size ?? button?.originalSize, | ||||
|           scale: scale, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           children: children, | ||||
|           priority: priority, | ||||
|         ); | ||||
|  | ||||
|   @override | ||||
|  | ||||
| @ -56,23 +56,14 @@ class IsometricTileMapComponent extends PositionComponent { | ||||
|     this.matrix, { | ||||
|     this.destTileSize, | ||||
|     this.tileHeight, | ||||
|     Vector2? position, | ||||
|     Vector2? size, | ||||
|     Vector2? scale, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     Iterable<Component>? children, | ||||
|     int? priority, | ||||
|   })  : _renderSprite = Sprite(tileset.image), | ||||
|         super( | ||||
|           position: position, | ||||
|           size: size, | ||||
|           scale: scale, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           children: children, | ||||
|           priority: priority, | ||||
|         ); | ||||
|     super.position, | ||||
|     super.size, | ||||
|     super.scale, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|     super.children, | ||||
|     super.priority, | ||||
|   }) : _renderSprite = Sprite(tileset.image); | ||||
|  | ||||
|   /// This is the size the tiles will be drawn (either original or overwritten). | ||||
|   Vector2 get effectiveTileSize => destTileSize ?? tileset.srcSize; | ||||
|  | ||||
| @ -17,22 +17,14 @@ class NineTileBoxComponent extends PositionComponent implements SizeProvider { | ||||
|   /// [PositionComponent] to render. | ||||
|   NineTileBoxComponent({ | ||||
|     this.nineTileBox, | ||||
|     Vector2? position, | ||||
|     Vector2? size, | ||||
|     Vector2? scale, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     Iterable<Component>? children, | ||||
|     int? priority, | ||||
|   }) : super( | ||||
|           position: position, | ||||
|           size: size, | ||||
|           scale: scale, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           children: children, | ||||
|           priority: priority, | ||||
|         ); | ||||
|     super.position, | ||||
|     super.size, | ||||
|     super.scale, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|     super.children, | ||||
|     super.priority, | ||||
|   }); | ||||
|  | ||||
|   @override | ||||
|   @mustCallSuper | ||||
|  | ||||
| @ -60,23 +60,17 @@ class ParallaxComponent<T extends FlameGame> extends PositionComponent | ||||
|   /// Creates a component with an empty parallax which can be set later. | ||||
|   ParallaxComponent({ | ||||
|     Parallax? parallax, | ||||
|     Vector2? position, | ||||
|     super.position, | ||||
|     Vector2? size, | ||||
|     Vector2? scale, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     Iterable<Component>? children, | ||||
|     int? priority, | ||||
|     super.scale, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|     super.children, | ||||
|     super.priority, | ||||
|   })  : _parallax = parallax, | ||||
|         isFullscreen = size == null && !(parallax?.isSized ?? false), | ||||
|         super( | ||||
|           position: position, | ||||
|           size: size ?? ((parallax?.isSized ?? false) ? parallax?.size : null), | ||||
|           scale: scale, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           children: children, | ||||
|           priority: priority, | ||||
|         ); | ||||
|  | ||||
|   @mustCallSuper | ||||
|  | ||||
| @ -14,20 +14,13 @@ class ParticleSystemComponent extends PositionComponent { | ||||
|   /// {@macro particle_system_component} | ||||
|   ParticleSystemComponent({ | ||||
|     this.particle, | ||||
|     Vector2? position, | ||||
|     Vector2? size, | ||||
|     Vector2? scale, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     int? priority, | ||||
|   }) : super( | ||||
|           position: position, | ||||
|           size: size, | ||||
|           scale: scale, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           priority: priority, | ||||
|         ); | ||||
|     super.position, | ||||
|     super.size, | ||||
|     super.scale, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|     super.priority, | ||||
|   }); | ||||
|  | ||||
|   /// Returns progress of the child [Particle]. | ||||
|   /// | ||||
|  | ||||
| @ -73,12 +73,11 @@ class PositionComponent extends Component | ||||
|     Vector2? scale, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     Iterable<Component>? children, | ||||
|     int? priority, | ||||
|     super.children, | ||||
|     super.priority, | ||||
|   })  : transform = Transform2D(), | ||||
|         _anchor = anchor ?? Anchor.topLeft, | ||||
|         _size = NotifyingVector2.copy(size ?? Vector2.zero()), | ||||
|         super(children: children, priority: priority) { | ||||
|         _size = NotifyingVector2.copy(size ?? Vector2.zero()) { | ||||
|     if (position != null) { | ||||
|       transform.position = position; | ||||
|     } | ||||
|  | ||||
| @ -26,24 +26,15 @@ class SpriteAnimationComponent extends PositionComponent | ||||
|     bool? removeOnFinish, | ||||
|     bool? playing, | ||||
|     Paint? paint, | ||||
|     Vector2? position, | ||||
|     Vector2? size, | ||||
|     Vector2? scale, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     Iterable<Component>? children, | ||||
|     int? priority, | ||||
|     super.position, | ||||
|     super.size, | ||||
|     super.scale, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|     super.children, | ||||
|     super.priority, | ||||
|   })  : removeOnFinish = removeOnFinish ?? false, | ||||
|         playing = playing ?? true, | ||||
|         super( | ||||
|           position: position, | ||||
|           size: size, | ||||
|           scale: scale, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           children: children, | ||||
|           priority: priority, | ||||
|         ) { | ||||
|         playing = playing ?? true { | ||||
|     if (paint != null) { | ||||
|       this.paint = paint; | ||||
|     } | ||||
|  | ||||
| @ -24,23 +24,14 @@ class SpriteAnimationGroupComponent<T> extends PositionComponent | ||||
|     this.current, | ||||
|     Map<T, bool>? removeOnFinish, | ||||
|     Paint? paint, | ||||
|     Vector2? position, | ||||
|     Vector2? size, | ||||
|     Vector2? scale, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     Iterable<Component>? children, | ||||
|     int? priority, | ||||
|   })  : removeOnFinish = removeOnFinish ?? const {}, | ||||
|         super( | ||||
|           position: position, | ||||
|           size: size, | ||||
|           scale: scale, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           children: children, | ||||
|           priority: priority, | ||||
|         ) { | ||||
|     super.position, | ||||
|     super.size, | ||||
|     super.scale, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|     super.children, | ||||
|     super.priority, | ||||
|   }) : removeOnFinish = removeOnFinish ?? const {} { | ||||
|     if (paint != null) { | ||||
|       this.paint = paint; | ||||
|     } | ||||
|  | ||||
| @ -22,21 +22,15 @@ class SpriteComponent extends PositionComponent | ||||
|   SpriteComponent({ | ||||
|     this.sprite, | ||||
|     Paint? paint, | ||||
|     Vector2? position, | ||||
|     super.position, | ||||
|     Vector2? size, | ||||
|     Vector2? scale, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     Iterable<Component>? children, | ||||
|     int? priority, | ||||
|     super.scale, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|     super.children, | ||||
|     super.priority, | ||||
|   }) : super( | ||||
|           position: position, | ||||
|           size: size ?? sprite?.srcSize, | ||||
|           scale: scale, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           children: children, | ||||
|           priority: priority, | ||||
|         ) { | ||||
|     if (paint != null) { | ||||
|       this.paint = paint; | ||||
|  | ||||
| @ -22,22 +22,14 @@ class SpriteGroupComponent<T> extends PositionComponent | ||||
|     this.sprites, | ||||
|     this.current, | ||||
|     Paint? paint, | ||||
|     Vector2? position, | ||||
|     Vector2? size, | ||||
|     Vector2? scale, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     Iterable<Component>? children, | ||||
|     int? priority, | ||||
|   }) : super( | ||||
|           position: position, | ||||
|           size: size, | ||||
|           scale: scale, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           children: children, | ||||
|           priority: priority, | ||||
|         ) { | ||||
|     super.position, | ||||
|     super.size, | ||||
|     super.scale, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|     super.children, | ||||
|     super.priority, | ||||
|   }) { | ||||
|     if (paint != null) { | ||||
|       this.paint = paint; | ||||
|     } | ||||
|  | ||||
| @ -65,33 +65,22 @@ class TextBoxComponent<T extends TextRenderer> extends TextComponent { | ||||
|   TextBoxConfig get boxConfig => _boxConfig; | ||||
|  | ||||
|   TextBoxComponent({ | ||||
|     String? text, | ||||
|     T? textRenderer, | ||||
|     super.text, | ||||
|     T? super.textRenderer, | ||||
|     TextBoxConfig? boxConfig, | ||||
|     Anchor? align, | ||||
|     double? pixelRatio, | ||||
|     Vector2? position, | ||||
|     Vector2? size, | ||||
|     Vector2? scale, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     Iterable<Component>? children, | ||||
|     int? priority, | ||||
|     super.position, | ||||
|     super.size, | ||||
|     super.scale, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|     super.children, | ||||
|     super.priority, | ||||
|   })  : _boxConfig = boxConfig ?? TextBoxConfig(), | ||||
|         _fixedSize = size != null, | ||||
|         align = align ?? Anchor.topLeft, | ||||
|         pixelRatio = pixelRatio ?? window.devicePixelRatio, | ||||
|         super( | ||||
|           text: text, | ||||
|           textRenderer: textRenderer, | ||||
|           position: position, | ||||
|           scale: scale, | ||||
|           size: size, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           children: children, | ||||
|           priority: priority, | ||||
|         ); | ||||
|         pixelRatio = pixelRatio ?? window.devicePixelRatio; | ||||
|  | ||||
|   /// Alignment of the text within its bounding box. | ||||
|   /// | ||||
|  | ||||
| @ -28,24 +28,15 @@ class TextComponent<T extends TextRenderer> extends PositionComponent { | ||||
|   TextComponent({ | ||||
|     String? text, | ||||
|     T? textRenderer, | ||||
|     Vector2? position, | ||||
|     Vector2? size, | ||||
|     Vector2? scale, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     Iterable<Component>? children, | ||||
|     int? priority, | ||||
|     super.position, | ||||
|     super.size, | ||||
|     super.scale, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|     super.children, | ||||
|     super.priority, | ||||
|   })  : _text = text ?? '', | ||||
|         _textRenderer = textRenderer ?? TextRenderer.createDefault<T>(), | ||||
|         super( | ||||
|           position: position, | ||||
|           size: size, | ||||
|           scale: scale, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           children: children, | ||||
|           priority: priority, | ||||
|         ) { | ||||
|         _textRenderer = textRenderer ?? TextRenderer.createDefault<T>() { | ||||
|     updateBounds(); | ||||
|   } | ||||
|  | ||||
|  | ||||
| @ -19,10 +19,10 @@ abstract class AnchorEffect extends Effect | ||||
|     with EffectTarget<AnchorProvider> | ||||
|     implements MeasurableEffect { | ||||
|   AnchorEffect( | ||||
|     EffectController controller, | ||||
|     super.controller, | ||||
|     AnchorProvider? target, { | ||||
|     void Function()? onComplete, | ||||
|   }) : super(controller, onComplete: onComplete) { | ||||
|     super.onComplete, | ||||
|   }) { | ||||
|     this.target = target; | ||||
|   } | ||||
|  | ||||
|  | ||||
| @ -1,5 +1,4 @@ | ||||
| import 'package:flame/components.dart'; | ||||
| import 'package:flame/src/effects/controllers/effect_controller.dart'; | ||||
| import 'package:flame/src/effects/effect.dart'; | ||||
|  | ||||
| /// Base class for effects that target a [Component] of type [T]. | ||||
| @ -8,9 +7,9 @@ import 'package:flame/src/effects/effect.dart'; | ||||
| /// used by `SizeEffect`, `OpacityEffect` and `Transform2DEffect`. | ||||
| abstract class ComponentEffect<T extends Component> extends Effect { | ||||
|   ComponentEffect( | ||||
|     EffectController controller, { | ||||
|     void Function()? onComplete, | ||||
|   }) : super(controller, onComplete: onComplete); | ||||
|     super.controller, { | ||||
|     super.onComplete, | ||||
|   }); | ||||
|  | ||||
|   late T target; | ||||
|  | ||||
|  | ||||
| @ -4,10 +4,9 @@ import 'package:flutter/animation.dart'; | ||||
| /// A controller that grows non-linearly from 0 to 1 following the provided | ||||
| /// [curve]. The [duration] cannot be 0. | ||||
| class CurvedEffectController extends DurationEffectController { | ||||
|   CurvedEffectController(double duration, Curve curve) | ||||
|   CurvedEffectController(super.duration, Curve curve) | ||||
|       : assert(duration > 0, 'Duration must be positive: $duration'), | ||||
|         _curve = curve, | ||||
|         super(duration); | ||||
|         _curve = curve; | ||||
|  | ||||
|   Curve get curve => _curve; | ||||
|   final Curve _curve; | ||||
|  | ||||
| @ -5,7 +5,7 @@ import 'package:flame/src/effects/controllers/duration_effect_controller.dart'; | ||||
| /// The [duration] can also be 0, in which case the effect will jump from 0 to 1 | ||||
| /// instantaneously. | ||||
| class LinearEffectController extends DurationEffectController { | ||||
|   LinearEffectController(double duration) : super(duration); | ||||
|   LinearEffectController(super.duration); | ||||
|  | ||||
|   // If duration is 0, `completed` will be true, and division by 0 avoided. | ||||
|   @override | ||||
|  | ||||
| @ -10,9 +10,8 @@ import 'package:flame/src/effects/controllers/duration_effect_controller.dart'; | ||||
| /// example, you can create a repeated controller where the progress changes | ||||
| /// 0->1->0 over a short period of time, then pauses, and this sequence repeats. | ||||
| class PauseEffectController extends DurationEffectController { | ||||
|   PauseEffectController(double duration, {required double progress}) | ||||
|       : _progress = progress, | ||||
|         super(duration); | ||||
|   PauseEffectController(super.duration, {required double progress}) | ||||
|       : _progress = progress; | ||||
|  | ||||
|   final double _progress; | ||||
|  | ||||
|  | ||||
| @ -4,10 +4,9 @@ import 'package:flutter/animation.dart'; | ||||
| /// A controller that grows non-linearly from 1 to 0 following the provided | ||||
| /// [curve]. The [duration] cannot be 0. | ||||
| class ReverseCurvedEffectController extends DurationEffectController { | ||||
|   ReverseCurvedEffectController(double duration, Curve curve) | ||||
|   ReverseCurvedEffectController(super.duration, Curve curve) | ||||
|       : assert(duration > 0, 'Duration must be positive: $duration'), | ||||
|         _curve = curve, | ||||
|         super(duration); | ||||
|         _curve = curve; | ||||
|  | ||||
|   Curve get curve => _curve; | ||||
|   final Curve _curve; | ||||
|  | ||||
| @ -5,7 +5,7 @@ import 'package:flame/src/effects/controllers/duration_effect_controller.dart'; | ||||
| /// The [duration] can also be 0, in which case the effect will jump from 1 to 0 | ||||
| /// instantaneously. | ||||
| class ReverseLinearEffectController extends DurationEffectController { | ||||
|   ReverseLinearEffectController(double duration) : super(duration); | ||||
|   ReverseLinearEffectController(super.duration); | ||||
|  | ||||
|   // If duration is 0, `completed` will be true, and division by 0 avoided. | ||||
|   @override | ||||
|  | ||||
| @ -18,10 +18,10 @@ abstract class MoveEffect extends Effect | ||||
|     with EffectTarget<PositionProvider> | ||||
|     implements MeasurableEffect { | ||||
|   MoveEffect( | ||||
|     EffectController controller, | ||||
|     super.controller, | ||||
|     PositionProvider? target, { | ||||
|     void Function()? onComplete, | ||||
|   }) : super(controller, onComplete: onComplete) { | ||||
|     super.onComplete, | ||||
|   }) { | ||||
|     this.target = target; | ||||
|   } | ||||
|  | ||||
|  | ||||
| @ -16,11 +16,10 @@ class OpacityEffect extends ComponentEffect<HasPaint> { | ||||
|   /// over time. | ||||
|   OpacityEffect.by( | ||||
|     double offset, | ||||
|     EffectController controller, { | ||||
|     super.controller, { | ||||
|     this.paintId, | ||||
|     void Function()? onComplete, | ||||
|   })  : _alphaOffset = (255 * offset).round(), | ||||
|         super(controller, onComplete: onComplete); | ||||
|     super.onComplete, | ||||
|   }) : _alphaOffset = (255 * offset).round(); | ||||
|  | ||||
|   /// This constructor will set the opacity to the specified opacity over time. | ||||
|   factory OpacityEffect.to( | ||||
|  | ||||
| @ -23,13 +23,9 @@ class RotateEffect extends Effect | ||||
|     implements MeasurableEffect { | ||||
|   RotateEffect.by( | ||||
|     double angle, | ||||
|     EffectController controller, { | ||||
|     void Function()? onComplete, | ||||
|   })  : _angle = angle, | ||||
|         super( | ||||
|           controller, | ||||
|           onComplete: onComplete, | ||||
|         ); | ||||
|     super.controller, { | ||||
|     super.onComplete, | ||||
|   }) : _angle = angle; | ||||
|  | ||||
|   factory RotateEffect.to( | ||||
|     double angle, | ||||
|  | ||||
| @ -18,10 +18,9 @@ import 'package:vector_math/vector_math_64.dart'; | ||||
| class ScaleEffect extends Effect with EffectTarget<ScaleProvider> { | ||||
|   ScaleEffect.by( | ||||
|     Vector2 scaleFactor, | ||||
|     EffectController controller, { | ||||
|     void Function()? onComplete, | ||||
|   })  : _scaleFactor = scaleFactor.clone(), | ||||
|         super(controller, onComplete: onComplete); | ||||
|     super.controller, { | ||||
|     super.onComplete, | ||||
|   }) : _scaleFactor = scaleFactor.clone(); | ||||
|  | ||||
|   factory ScaleEffect.to( | ||||
|     Vector2 targetScale, | ||||
|  | ||||
| @ -50,9 +50,9 @@ class SequenceEffect extends Effect { | ||||
|   } | ||||
|  | ||||
|   SequenceEffect._( | ||||
|     EffectController ec, { | ||||
|     void Function()? onComplete, | ||||
|   }) : super(ec, onComplete: onComplete); | ||||
|     super.ec, { | ||||
|     super.onComplete, | ||||
|   }); | ||||
|  | ||||
|   @override | ||||
|   void apply(double progress) {} | ||||
|  | ||||
| @ -18,11 +18,10 @@ class SizeEffect extends Effect with EffectTarget<SizeProvider> { | ||||
|   /// size at the same time. | ||||
|   SizeEffect.by( | ||||
|     Vector2 offset, | ||||
|     EffectController controller, { | ||||
|     super.controller, { | ||||
|     SizeProvider? target, | ||||
|     void Function()? onComplete, | ||||
|   })  : _offset = offset.clone(), | ||||
|         super(controller, onComplete: onComplete) { | ||||
|     super.onComplete, | ||||
|   }) : _offset = offset.clone() { | ||||
|     this.target = target; | ||||
|   } | ||||
|  | ||||
|  | ||||
| @ -1,6 +1,5 @@ | ||||
| import 'package:flame/src/components/position_component.dart'; | ||||
| import 'package:flame/src/effects/component_effect.dart'; | ||||
| import 'package:flame/src/effects/controllers/effect_controller.dart'; | ||||
| import 'package:flame/src/game/transform2d.dart'; | ||||
|  | ||||
| /// Base class for effects that target a [Transform2D] property. | ||||
| @ -14,9 +13,9 @@ import 'package:flame/src/game/transform2d.dart'; | ||||
| /// classes. | ||||
| abstract class Transform2DEffect extends ComponentEffect<PositionComponent> { | ||||
|   Transform2DEffect( | ||||
|     EffectController controller, { | ||||
|     void Function()? onComplete, | ||||
|   }) : super(controller, onComplete: onComplete); | ||||
|     super.controller, { | ||||
|     super.onComplete, | ||||
|   }); | ||||
|  | ||||
|   late Transform2D transform; | ||||
|  | ||||
|  | ||||
| @ -22,13 +22,12 @@ class BoundedPositionBehavior extends Component { | ||||
|     required Shape bounds, | ||||
|     PositionProvider? target, | ||||
|     double precision = 0.5, | ||||
|     int? priority, | ||||
|     super.priority, | ||||
|   })  : assert(precision > 0, 'Precision must be positive: $precision'), | ||||
|         _bounds = bounds, | ||||
|         _target = target, | ||||
|         _previousPosition = Vector2.zero(), | ||||
|         _precision = precision, | ||||
|         super(priority: priority); | ||||
|         _precision = precision; | ||||
|  | ||||
|   /// The region within which the target's position must be kept. | ||||
|   Shape get bounds => _bounds; | ||||
|  | ||||
| @ -1,13 +1,11 @@ | ||||
| import 'dart:ui'; | ||||
|  | ||||
| import 'package:flame/src/components/component.dart'; | ||||
| import 'package:flame/src/experimental/viewport.dart'; | ||||
| import 'package:vector_math/vector_math_64.dart'; | ||||
|  | ||||
| /// A fixed-size viewport in the shape of a circle. | ||||
| class CircularViewport extends Viewport { | ||||
|   CircularViewport(double radius, {Iterable<Component>? children}) | ||||
|       : super(children: children) { | ||||
|   CircularViewport(double radius, {super.children}) { | ||||
|     size = Vector2.all(2 * radius); | ||||
|   } | ||||
|  | ||||
|  | ||||
| @ -1,15 +1,13 @@ | ||||
| import 'dart:ui'; | ||||
|  | ||||
| import 'package:flame/src/components/component.dart'; | ||||
| import 'package:flame/src/experimental/viewport.dart'; | ||||
| import 'package:vector_math/vector_math_64.dart'; | ||||
|  | ||||
| class FixedAspectRatioViewport extends Viewport { | ||||
|   FixedAspectRatioViewport({ | ||||
|     required this.aspectRatio, | ||||
|     Iterable<Component>? children, | ||||
|   })  : assert(aspectRatio > 0), | ||||
|         super(children: children); | ||||
|     super.children, | ||||
|   }) : assert(aspectRatio > 0); | ||||
|  | ||||
|   final double aspectRatio; | ||||
|   Rect _clipRect = Rect.zero; | ||||
|  | ||||
| @ -1,6 +1,5 @@ | ||||
| import 'dart:ui'; | ||||
|  | ||||
| import 'package:flame/src/components/component.dart'; | ||||
| import 'package:flame/src/experimental/viewport.dart'; | ||||
| import 'package:vector_math/vector_math_64.dart'; | ||||
|  | ||||
| @ -12,8 +11,8 @@ class FixedSizeViewport extends Viewport { | ||||
|   FixedSizeViewport( | ||||
|     double width, | ||||
|     double height, { | ||||
|     Iterable<Component>? children, | ||||
|   }) : super(children: children) { | ||||
|     super.children, | ||||
|   }) { | ||||
|     size = Vector2(width, height); | ||||
|     onViewportResize(); | ||||
|   } | ||||
|  | ||||
| @ -23,7 +23,7 @@ class FollowBehavior extends Component { | ||||
|     double maxSpeed = double.infinity, | ||||
|     this.horizontalOnly = false, | ||||
|     this.verticalOnly = false, | ||||
|     int? priority, | ||||
|     super.priority, | ||||
|   })  : _target = target, | ||||
|         _owner = owner, | ||||
|         _speed = maxSpeed, | ||||
| @ -31,8 +31,7 @@ class FollowBehavior extends Component { | ||||
|         assert( | ||||
|           !(horizontalOnly && verticalOnly), | ||||
|           'The behavior cannot be both horizontalOnly and verticalOnly', | ||||
|         ), | ||||
|         super(priority: priority); | ||||
|         ); | ||||
|  | ||||
|   PositionProvider get target => _target; | ||||
|   final PositionProvider _target; | ||||
|  | ||||
| @ -1,6 +1,5 @@ | ||||
| import 'dart:ui'; | ||||
|  | ||||
| import 'package:flame/src/components/component.dart'; | ||||
| import 'package:flame/src/experimental/viewport.dart'; | ||||
| import 'package:vector_math/vector_math_64.dart'; | ||||
|  | ||||
| @ -8,7 +7,7 @@ import 'package:vector_math/vector_math_64.dart'; | ||||
| /// | ||||
| /// This viewport does not perform any clipping. | ||||
| class MaxViewport extends Viewport { | ||||
|   MaxViewport({Iterable<Component>? children}) : super(children: children); | ||||
|   MaxViewport({super.children}); | ||||
|  | ||||
|   @override | ||||
|   void onGameResize(Vector2 gameSize) { | ||||
|  | ||||
| @ -22,7 +22,7 @@ import 'package:vector_math/vector_math_64.dart'; | ||||
| /// the top left corner of the viewport's bounding box. | ||||
| abstract class Viewport extends Component | ||||
|     implements AnchorProvider, PositionProvider, SizeProvider { | ||||
|   Viewport({Iterable<Component>? children}) : super(children: children); | ||||
|   Viewport({super.children}); | ||||
|  | ||||
|   /// Position of the viewport's anchor in the parent's coordinate frame. | ||||
|   /// | ||||
|  | ||||
| @ -17,15 +17,15 @@ import 'package:meta/meta.dart'; | ||||
| /// It is based on the Flame Component System (also known as FCS). | ||||
| class FlameGame extends Component with Game { | ||||
|   FlameGame({ | ||||
|     Iterable<Component>? children, | ||||
|     super.children, | ||||
|     Camera? camera, | ||||
|   }) : super(children: children) { | ||||
|   }) { | ||||
|     assert( | ||||
|       Component.staticGameInstance == null, | ||||
|       '$this instantiated, while another game ${Component.staticGameInstance} ' | ||||
|       'declares itself to be a singleton', | ||||
|     ); | ||||
|     _cameraWrapper = CameraWrapper(camera ?? Camera(), this.children); | ||||
|     _cameraWrapper = CameraWrapper(camera ?? Camera(), children); | ||||
|   } | ||||
|  | ||||
|   late final CameraWrapper _cameraWrapper; | ||||
|  | ||||
| @ -115,7 +115,7 @@ class GameWidget<T extends Game> extends StatefulWidget { | ||||
|   /// game.overlays.add('PauseMenu'); | ||||
|   /// ``` | ||||
|   GameWidget({ | ||||
|     Key? key, | ||||
|     super.key, | ||||
|     required T this.game, | ||||
|     this.textDirection, | ||||
|     this.loadingBuilder, | ||||
| @ -126,8 +126,7 @@ class GameWidget<T extends Game> extends StatefulWidget { | ||||
|     this.focusNode, | ||||
|     this.autofocus = true, | ||||
|     MouseCursor? mouseCursor, | ||||
|   })  : gameFactory = null, | ||||
|         super(key: key) { | ||||
|   }) : gameFactory = null { | ||||
|     if (mouseCursor != null) { | ||||
|       game!.mouseCursor = mouseCursor; | ||||
|     } | ||||
| @ -157,7 +156,7 @@ class GameWidget<T extends Game> extends StatefulWidget { | ||||
|   /// ... | ||||
|   /// ``` | ||||
|   const GameWidget.controlled({ | ||||
|     Key? key, | ||||
|     super.key, | ||||
|     required GameFactory<T> this.gameFactory, | ||||
|     this.textDirection, | ||||
|     this.loadingBuilder, | ||||
| @ -166,8 +165,7 @@ class GameWidget<T extends Game> extends StatefulWidget { | ||||
|     this.overlayBuilderMap, | ||||
|     this.focusNode, | ||||
|     this.autofocus = true, | ||||
|   })  : game = null, | ||||
|         super(key: key); | ||||
|   }) : game = null; | ||||
|  | ||||
|   /// Renders a [game] in a flutter widget tree alongside widgets overlays. | ||||
|   /// | ||||
|  | ||||
| @ -1,5 +1,4 @@ | ||||
| import 'dart:math'; | ||||
| import 'dart:ui'; | ||||
|  | ||||
| import 'package:flame/components.dart'; | ||||
| import 'package:flame/extensions.dart'; | ||||
| @ -13,20 +12,14 @@ class CircleComponent extends ShapeComponent implements SizeProvider { | ||||
|   /// the [CircleComponent]. | ||||
|   CircleComponent({ | ||||
|     double? radius, | ||||
|     Vector2? position, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     Iterable<Component>? children, | ||||
|     int? priority, | ||||
|     Paint? paint, | ||||
|     super.position, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|     super.children, | ||||
|     super.priority, | ||||
|     super.paint, | ||||
|   }) : super( | ||||
|           position: position, | ||||
|           size: Vector2.all((radius ?? 0) * 2), | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           children: children, | ||||
|           priority: priority, | ||||
|           paint: paint, | ||||
|         ); | ||||
|  | ||||
|   /// With this constructor you define the [CircleComponent] in relation to the | ||||
|  | ||||
| @ -4,7 +4,6 @@ import 'dart:ui'; | ||||
| import 'package:collection/collection.dart'; | ||||
| import 'package:flame/src/anchor.dart'; | ||||
| import 'package:flame/src/cache/value_cache.dart'; | ||||
| import 'package:flame/src/components/component.dart'; | ||||
| import 'package:flame/src/extensions/rect.dart'; | ||||
| import 'package:flame/src/extensions/vector2.dart'; | ||||
| import 'package:flame/src/geometry/line_segment.dart'; | ||||
| @ -32,31 +31,21 @@ class PolygonComponent extends ShapeComponent { | ||||
|   /// screen coordinate system). | ||||
|   PolygonComponent( | ||||
|     this._vertices, { | ||||
|     Vector2? position, | ||||
|     Vector2? size, | ||||
|     Vector2? scale, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     Iterable<Component>? children, | ||||
|     int? priority, | ||||
|     Paint? paint, | ||||
|     super.position, | ||||
|     super.size, | ||||
|     super.scale, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|     super.children, | ||||
|     super.priority, | ||||
|     super.paint, | ||||
|     bool? shrinkToBounds, | ||||
|   })  : assert( | ||||
|           _vertices.length > 2, | ||||
|           'Number of vertices are too few to create a polygon', | ||||
|         ), | ||||
|         shrinkToBounds = shrinkToBounds ?? size == null, | ||||
|         manuallyPositioned = position != null, | ||||
|         super( | ||||
|           position: position, | ||||
|           size: size, | ||||
|           scale: scale, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           children: children, | ||||
|           priority: priority, | ||||
|           paint: paint, | ||||
|         ) { | ||||
|         manuallyPositioned = position != null { | ||||
|     refreshVertices(newVertices: _vertices); | ||||
|  | ||||
|     final verticesLength = _vertices.length; | ||||
|  | ||||
| @ -10,23 +10,15 @@ abstract class ShapeComponent extends PositionComponent with HasPaint { | ||||
|   bool renderShape = true; | ||||
|  | ||||
|   ShapeComponent({ | ||||
|     Vector2? position, | ||||
|     Vector2? size, | ||||
|     Vector2? scale, | ||||
|     double? angle, | ||||
|     Anchor? anchor, | ||||
|     Iterable<Component>? children, | ||||
|     int? priority, | ||||
|     super.position, | ||||
|     super.size, | ||||
|     super.scale, | ||||
|     super.angle, | ||||
|     super.anchor, | ||||
|     super.children, | ||||
|     super.priority, | ||||
|     Paint? paint, | ||||
|   }) : super( | ||||
|           position: position, | ||||
|           size: size, | ||||
|           scale: scale, | ||||
|           angle: angle, | ||||
|           anchor: anchor, | ||||
|           children: children, | ||||
|           priority: priority, | ||||
|         ) { | ||||
|   }) { | ||||
|     this.paint = paint ?? this.paint; | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -117,16 +117,11 @@ class ParallaxImage extends ParallaxRenderer { | ||||
|  | ||||
|   ParallaxImage( | ||||
|     this._image, { | ||||
|     ImageRepeat? repeat, | ||||
|     Alignment? alignment, | ||||
|     LayerFill? fill, | ||||
|     FilterQuality? filterQuality, | ||||
|   }) : super( | ||||
|           repeat: repeat, | ||||
|           alignment: alignment, | ||||
|           fill: fill, | ||||
|           filterQuality: filterQuality, | ||||
|         ); | ||||
|     super.repeat, | ||||
|     super.alignment, | ||||
|     super.fill, | ||||
|     super.filterQuality, | ||||
|   }); | ||||
|  | ||||
|   /// Takes a path of an image, and optionally arguments for how the image | ||||
|   /// should repeat ([repeat]), which edge it should align with ([alignment]), | ||||
| @ -172,14 +167,10 @@ class ParallaxAnimation extends ParallaxRenderer { | ||||
|   ParallaxAnimation( | ||||
|     this._animation, | ||||
|     this._prerenderedFrames, { | ||||
|     ImageRepeat? repeat, | ||||
|     Alignment? alignment, | ||||
|     LayerFill? fill, | ||||
|   }) : super( | ||||
|           repeat: repeat, | ||||
|           alignment: alignment, | ||||
|           fill: fill, | ||||
|         ); | ||||
|     super.repeat, | ||||
|     super.alignment, | ||||
|     super.fill, | ||||
|   }); | ||||
|  | ||||
|   /// Takes a path of an image, a SpriteAnimationData, and optionally arguments | ||||
|   /// for how the image should repeat ([repeat]), which edge it should align | ||||
|  | ||||
| @ -26,11 +26,10 @@ class AcceleratedParticle extends CurvedParticle with SingleChildParticle { | ||||
|     Vector2? acceleration, | ||||
|     Vector2? speed, | ||||
|     Vector2? position, | ||||
|     double? lifespan, | ||||
|     super.lifespan, | ||||
|   })  : acceleration = acceleration ?? Vector2.zero(), | ||||
|         position = position ?? Vector2.zero(), | ||||
|         speed = speed ?? Vector2.zero(), | ||||
|         super(lifespan: lifespan); | ||||
|         speed = speed ?? Vector2.zero(); | ||||
|  | ||||
|   @override | ||||
|   void render(Canvas canvas) { | ||||
|  | ||||
| @ -18,11 +18,9 @@ class SpriteAnimationParticle extends Particle { | ||||
|     required this.animation, | ||||
|     this.size, | ||||
|     this.overridePaint, | ||||
|     double? lifespan, | ||||
|     super.lifespan, | ||||
|     this.alignAnimationTime = true, | ||||
|   }) : super( | ||||
|           lifespan: lifespan, | ||||
|         ); | ||||
|   }); | ||||
|  | ||||
|   @override | ||||
|   void setLifespan(double lifespan) { | ||||
|  | ||||
| @ -12,8 +12,8 @@ class CircleParticle extends Particle { | ||||
|   CircleParticle({ | ||||
|     required this.paint, | ||||
|     this.radius = 10.0, | ||||
|     double? lifespan, | ||||
|   }) : super(lifespan: lifespan); | ||||
|     super.lifespan, | ||||
|   }); | ||||
|  | ||||
|   @override | ||||
|   void render(Canvas c) { | ||||
|  | ||||
| @ -13,10 +13,8 @@ class ComponentParticle extends Particle { | ||||
|     required this.component, | ||||
|     this.size, | ||||
|     this.overridePaint, | ||||
|     double? lifespan, | ||||
|   }) : super( | ||||
|           lifespan: lifespan, | ||||
|         ); | ||||
|     super.lifespan, | ||||
|   }); | ||||
|  | ||||
|   @override | ||||
|   void render(Canvas canvas) { | ||||
|  | ||||
| @ -9,10 +9,8 @@ class ComposedParticle extends Particle { | ||||
|  | ||||
|   ComposedParticle({ | ||||
|     required this.children, | ||||
|     double? lifespan, | ||||
|   }) : super( | ||||
|           lifespan: lifespan, | ||||
|         ); | ||||
|     super.lifespan, | ||||
|   }); | ||||
|  | ||||
|   @override | ||||
|   void setLifespan(double lifespan) { | ||||
|  | ||||
| @ -16,10 +16,8 @@ class ComputedParticle extends Particle { | ||||
|  | ||||
|   ComputedParticle({ | ||||
|     required this.renderer, | ||||
|     double? lifespan, | ||||
|   }) : super( | ||||
|           lifespan: lifespan, | ||||
|         ); | ||||
|     super.lifespan, | ||||
|   }); | ||||
|  | ||||
|   @override | ||||
|   void render(Canvas canvas) { | ||||
|  | ||||
| @ -8,10 +8,8 @@ class CurvedParticle extends Particle { | ||||
|  | ||||
|   CurvedParticle({ | ||||
|     this.curve = Curves.linear, | ||||
|     double? lifespan, | ||||
|   }) : super( | ||||
|           lifespan: lifespan, | ||||
|         ); | ||||
|     super.lifespan, | ||||
|   }); | ||||
|  | ||||
|   @override | ||||
|   double get progress => curve.transform(super.progress); | ||||
|  | ||||
| @ -15,8 +15,8 @@ class ImageParticle extends Particle { | ||||
|   ImageParticle({ | ||||
|     required this.image, | ||||
|     Vector2? size, | ||||
|     double? lifespan, | ||||
|   }) : super(lifespan: lifespan) { | ||||
|     super.lifespan, | ||||
|   }) { | ||||
|     final srcWidth = image.width.toDouble(); | ||||
|     final srcHeight = image.height.toDouble(); | ||||
|     final destWidth = size?.x ?? srcWidth; | ||||
|  | ||||
| @ -2,7 +2,6 @@ import 'package:flame/extensions.dart'; | ||||
| import 'package:flame/src/components/mixins/single_child_particle.dart'; | ||||
| import 'package:flame/src/particles/curved_particle.dart'; | ||||
| import 'package:flame/src/particles/particle.dart'; | ||||
| import 'package:flutter/animation.dart'; | ||||
|  | ||||
| /// Statically move given child [Particle] by given [Vector2]. | ||||
| /// | ||||
| @ -18,10 +17,9 @@ class MovingParticle extends CurvedParticle with SingleChildParticle { | ||||
|     required this.child, | ||||
|     required this.to, | ||||
|     Vector2? from, | ||||
|     double? lifespan, | ||||
|     Curve curve = Curves.linear, | ||||
|   })  : from = from ?? Vector2.zero(), | ||||
|         super(lifespan: lifespan, curve: curve); | ||||
|     super.lifespan, | ||||
|     super.curve, | ||||
|   }) : from = from ?? Vector2.zero(); | ||||
|  | ||||
|   /// Used to avoid creating new [Vector2] objects in [update]. | ||||
|   static final _tmpVector = Vector2.zero(); | ||||
|  | ||||
| @ -25,10 +25,8 @@ class PaintParticle extends CurvedParticle with SingleChildParticle { | ||||
|  | ||||
|     // Reasonably large rect for most particles | ||||
|     this.bounds = const Rect.fromLTRB(-50, -50, 50, 50), | ||||
|     double? lifespan, | ||||
|   }) : super( | ||||
|           lifespan: lifespan, | ||||
|         ); | ||||
|     super.lifespan, | ||||
|   }); | ||||
|  | ||||
|   @override | ||||
|   void render(Canvas canvas) { | ||||
|  | ||||
| @ -18,10 +18,8 @@ class RotatingParticle extends CurvedParticle with SingleChildParticle { | ||||
|     required this.child, | ||||
|     this.from = 0, | ||||
|     this.to = 2 * pi, | ||||
|     double? lifespan, | ||||
|   }) : super( | ||||
|           lifespan: lifespan, | ||||
|         ); | ||||
|     super.lifespan, | ||||
|   }); | ||||
|  | ||||
|   double get angle => lerpDouble(from, to, progress) ?? 0; | ||||
|  | ||||
|  | ||||
| @ -15,10 +15,8 @@ class ScaledParticle extends CurvedParticle with SingleChildParticle { | ||||
|   ScaledParticle({ | ||||
|     required this.child, | ||||
|     this.scale = 1.0, | ||||
|     double? lifespan, | ||||
|   }) : super( | ||||
|           lifespan: lifespan, | ||||
|         ); | ||||
|     super.lifespan, | ||||
|   }); | ||||
|  | ||||
|   @override | ||||
|   void render(Canvas canvas) { | ||||
|  | ||||
| @ -17,10 +17,8 @@ class SpriteParticle extends Particle { | ||||
|     required this.sprite, | ||||
|     this.size, | ||||
|     this.overridePaint, | ||||
|     double? lifespan, | ||||
|   }) : super( | ||||
|           lifespan: lifespan, | ||||
|         ); | ||||
|     super.lifespan, | ||||
|   }); | ||||
|  | ||||
|   @override | ||||
|   void render(Canvas canvas) { | ||||
|  | ||||
| @ -14,8 +14,8 @@ class TranslatedParticle extends Particle with SingleChildParticle { | ||||
|   TranslatedParticle({ | ||||
|     required this.child, | ||||
|     required this.offset, | ||||
|     double? lifespan, | ||||
|   }) : super(lifespan: lifespan); | ||||
|     super.lifespan, | ||||
|   }); | ||||
|  | ||||
|   @override | ||||
|   void render(Canvas c) { | ||||
|  | ||||
| @ -30,11 +30,10 @@ class SpriteAnimationWidget extends StatelessWidget { | ||||
|     required SpriteAnimation animation, | ||||
|     this.playing = true, | ||||
|     this.anchor = Anchor.topLeft, | ||||
|     Key? key, | ||||
|     super.key, | ||||
|   })  : _animationFuture = animation, | ||||
|         errorBuilder = null, | ||||
|         loadingBuilder = null, | ||||
|         super(key: key); | ||||
|         loadingBuilder = null; | ||||
|  | ||||
|   /// Loads image from the asset [path] and renders it as a widget. | ||||
|   /// | ||||
| @ -50,13 +49,12 @@ class SpriteAnimationWidget extends StatelessWidget { | ||||
|     this.anchor = Anchor.topLeft, | ||||
|     this.errorBuilder, | ||||
|     this.loadingBuilder, | ||||
|     Key? key, | ||||
|     super.key, | ||||
|   }) : _animationFuture = SpriteAnimation.load( | ||||
|           path, | ||||
|           data, | ||||
|           images: images, | ||||
|         ), | ||||
|         super(key: key); | ||||
|         ); | ||||
|  | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
| @ -91,8 +89,8 @@ class InternalSpriteAnimationWidget extends StatefulWidget { | ||||
|     required this.animation, | ||||
|     this.playing = true, | ||||
|     this.anchor = Anchor.topLeft, | ||||
|     Key? key, | ||||
|   }) : super(key: key); | ||||
|     super.key, | ||||
|   }); | ||||
|  | ||||
|   @override | ||||
|   State createState() => _InternalSpriteAnimationWidgetState(); | ||||
|  | ||||
| @ -13,8 +13,8 @@ class BaseFutureBuilder<T> extends StatelessWidget { | ||||
|     required this.builder, | ||||
|     this.loadingBuilder, | ||||
|     this.errorBuilder, | ||||
|     Key? key, | ||||
|   }) : super(key: key); | ||||
|     super.key, | ||||
|   }); | ||||
|  | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|  | ||||
| @ -66,11 +66,10 @@ class NineTileBoxWidget extends StatelessWidget { | ||||
|     this.height, | ||||
|     this.child, | ||||
|     this.padding, | ||||
|     Key? key, | ||||
|     super.key, | ||||
|   })  : _imageFuture = image, | ||||
|         errorBuilder = null, | ||||
|         loadingBuilder = null, | ||||
|         super(key: key); | ||||
|         loadingBuilder = null; | ||||
|  | ||||
|   /// Loads image from the asset [path] and renders it as a widget. | ||||
|   /// | ||||
| @ -89,9 +88,8 @@ class NineTileBoxWidget extends StatelessWidget { | ||||
|     this.padding, | ||||
|     this.errorBuilder, | ||||
|     this.loadingBuilder, | ||||
|     Key? key, | ||||
|   })  : _imageFuture = (images ?? Flame.images).load(path), | ||||
|         super(key: key); | ||||
|     super.key, | ||||
|   }) : _imageFuture = (images ?? Flame.images).load(path); | ||||
|  | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
| @ -134,8 +132,8 @@ class InternalNineTileBox extends StatelessWidget { | ||||
|     this.width, | ||||
|     this.height, | ||||
|     this.padding, | ||||
|     Key? key, | ||||
|   }) : super(key: key); | ||||
|     super.key, | ||||
|   }); | ||||
|  | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|  | ||||
| @ -51,14 +51,13 @@ class SpriteButton extends StatelessWidget { | ||||
|     this.srcSize, | ||||
|     this.pressedSrcPosition, | ||||
|     this.pressedSrcSize, | ||||
|     Key? key, | ||||
|     super.key, | ||||
|   })  : _buttonsFuture = [ | ||||
|           sprite, | ||||
|           pressedSprite, | ||||
|         ], | ||||
|         errorBuilder = null, | ||||
|         loadingBuilder = null, | ||||
|         super(key: key); | ||||
|         loadingBuilder = null; | ||||
|  | ||||
|   SpriteButton.future({ | ||||
|     required Future<Sprite> sprite, | ||||
| @ -73,12 +72,11 @@ class SpriteButton extends StatelessWidget { | ||||
|     this.pressedSrcSize, | ||||
|     this.errorBuilder, | ||||
|     this.loadingBuilder, | ||||
|     Key? key, | ||||
|     super.key, | ||||
|   }) : _buttonsFuture = Future.wait([ | ||||
|           sprite, | ||||
|           pressedSprite, | ||||
|         ]), | ||||
|         super(key: key); | ||||
|         ]); | ||||
|  | ||||
|   /// Loads the images from the asset [path] and [pressedPath] and renders | ||||
|   /// it as a widget. | ||||
| @ -101,7 +99,7 @@ class SpriteButton extends StatelessWidget { | ||||
|     this.pressedSrcSize, | ||||
|     this.errorBuilder, | ||||
|     this.loadingBuilder, | ||||
|     Key? key, | ||||
|     super.key, | ||||
|   }) : _buttonsFuture = Future.wait([ | ||||
|           Sprite.load( | ||||
|             path, | ||||
| @ -115,8 +113,7 @@ class SpriteButton extends StatelessWidget { | ||||
|             srcPosition: pressedSrcPosition, | ||||
|             images: images, | ||||
|           ), | ||||
|         ]), | ||||
|         super(key: key); | ||||
|         ]); | ||||
|  | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
| @ -157,8 +154,8 @@ class InternalSpriteButton extends StatefulWidget { | ||||
|     required this.pressedSprite, | ||||
|     this.width = 200, | ||||
|     this.height = 50, | ||||
|     Key? key, | ||||
|   }) : super(key: key); | ||||
|     super.key, | ||||
|   }); | ||||
|  | ||||
|   @override | ||||
|   State createState() => _ButtonState(); | ||||
|  | ||||
| @ -39,11 +39,10 @@ class SpriteWidget extends StatelessWidget { | ||||
|     this.angle = 0, | ||||
|     this.srcPosition, | ||||
|     this.srcSize, | ||||
|     Key? key, | ||||
|     super.key, | ||||
|   })  : _spriteFuture = sprite, | ||||
|         errorBuilder = null, | ||||
|         loadingBuilder = null, | ||||
|         super(key: key); | ||||
|         loadingBuilder = null; | ||||
|  | ||||
|   /// Load the image from the asset [path] and renders it as a widget. | ||||
|   /// | ||||
| @ -60,14 +59,13 @@ class SpriteWidget extends StatelessWidget { | ||||
|     this.srcSize, | ||||
|     this.errorBuilder, | ||||
|     this.loadingBuilder, | ||||
|     Key? key, | ||||
|     super.key, | ||||
|   }) : _spriteFuture = Sprite.load( | ||||
|           path, | ||||
|           srcSize: srcSize, | ||||
|           srcPosition: srcPosition, | ||||
|           images: images, | ||||
|         ), | ||||
|         super(key: key); | ||||
|         ); | ||||
|  | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
| @ -102,8 +100,8 @@ class InternalSpriteWidget extends StatelessWidget { | ||||
|     required this.sprite, | ||||
|     this.anchor = Anchor.topLeft, | ||||
|     this.angle = 0, | ||||
|     Key? key, | ||||
|   }) : super(key: key); | ||||
|     super.key, | ||||
|   }); | ||||
|  | ||||
|   @override | ||||
|   Widget build(_) { | ||||
|  | ||||
| @ -4,8 +4,8 @@ version: 1.2.0 | ||||
| homepage: https://github.com/flame-engine/flame | ||||
|  | ||||
| environment: | ||||
|   sdk: ">=2.16.0 <3.0.0" | ||||
|   flutter: ">=2.10.0" | ||||
|   sdk: ">=2.17.0 <3.0.0" | ||||
|   flutter: ^3.0.0 | ||||
|  | ||||
| dependencies: | ||||
|   collection: ^1.15.0 | ||||
|  | ||||
| @ -681,8 +681,7 @@ class IntComponent extends Component { | ||||
| } | ||||
|  | ||||
| class TwoChildrenComponent extends Component { | ||||
|   TwoChildrenComponent({Iterable<Component>? children}) | ||||
|       : super(children: children); | ||||
|   TwoChildrenComponent({super.children}); | ||||
|  | ||||
|   late final Component child1; | ||||
|   late final Component child2; | ||||
|  | ||||
| @ -126,11 +126,11 @@ void main() { | ||||
|  | ||||
| class _FramedTextBox extends TextBoxComponent { | ||||
|   _FramedTextBox({ | ||||
|     required String text, | ||||
|     Anchor? align, | ||||
|     Vector2? position, | ||||
|     Vector2? size, | ||||
|   }) : super(text: text, align: align, position: position, size: size); | ||||
|     required String super.text, | ||||
|     super.align, | ||||
|     super.position, | ||||
|     super.size, | ||||
|   }); | ||||
|  | ||||
|   final Paint _borderPaint = Paint() | ||||
|     ..style = PaintingStyle.stroke | ||||
|  | ||||
| @ -134,7 +134,7 @@ void main() { | ||||
| } | ||||
|  | ||||
| class BadEffect extends Effect implements MeasurableEffect { | ||||
|   BadEffect(EffectController controller) : super(controller); | ||||
|   BadEffect(super.controller); | ||||
|  | ||||
|   @override | ||||
|   void apply(double progress) {} | ||||
|  | ||||
| @ -5,7 +5,7 @@ import 'package:flame_test/flame_test.dart'; | ||||
| import 'package:flutter_test/flutter_test.dart'; | ||||
|  | ||||
| class _MyEffect extends Effect { | ||||
|   _MyEffect(EffectController controller) : super(controller); | ||||
|   _MyEffect(super.controller); | ||||
|  | ||||
|   double x = -1; | ||||
|   Function()? onStartCallback; | ||||
|  | ||||
| @ -5,7 +5,7 @@ import 'package:flame_test/flame_test.dart'; | ||||
| import 'package:flutter_test/flutter_test.dart'; | ||||
|  | ||||
| class _MyEffect extends Transform2DEffect { | ||||
|   _MyEffect(EffectController controller) : super(controller); | ||||
|   _MyEffect(super.controller); | ||||
|  | ||||
|   @override | ||||
|   void apply(double progress) {} | ||||
|  | ||||
| @ -268,21 +268,19 @@ void main() { | ||||
|  | ||||
| class _GameWithHasTappableComponents extends FlameGame | ||||
|     with HasTappableComponents { | ||||
|   _GameWithHasTappableComponents({Iterable<Component>? children}) | ||||
|       : super(children: children); | ||||
|   _GameWithHasTappableComponents({super.children}); | ||||
| } | ||||
|  | ||||
| class _GameWithDualTappableComponents extends FlameGame | ||||
|     with HasTappableComponents, HasTappablesBridge { | ||||
|   _GameWithDualTappableComponents({Iterable<Component>? children}) | ||||
|       : super(children: children); | ||||
|   _GameWithDualTappableComponents({super.children}); | ||||
| } | ||||
|  | ||||
| class _TapCallbacksComponent extends PositionComponent with TapCallbacks { | ||||
|   _TapCallbacksComponent({ | ||||
|     Iterable<Component>? children, | ||||
|     required Vector2 position, | ||||
|     required Vector2 size, | ||||
|     super.children, | ||||
|     required Vector2 super.position, | ||||
|     required Vector2 super.size, | ||||
|     void Function(TapDownEvent)? onTapDown, | ||||
|     void Function(TapDownEvent)? onLongTapDown, | ||||
|     void Function(TapUpEvent)? onTapUp, | ||||
| @ -290,8 +288,7 @@ class _TapCallbacksComponent extends PositionComponent with TapCallbacks { | ||||
|   })  : _onTapDown = onTapDown, | ||||
|         _onLongTapDown = onLongTapDown, | ||||
|         _onTapUp = onTapUp, | ||||
|         _onTapCancel = onTapCancel, | ||||
|         super(children: children, position: position, size: size); | ||||
|         _onTapCancel = onTapCancel; | ||||
|  | ||||
|   final void Function(TapDownEvent)? _onTapDown; | ||||
|   final void Function(TapDownEvent)? _onLongTapDown; | ||||
| @ -312,8 +309,7 @@ class _TapCallbacksComponent extends PositionComponent with TapCallbacks { | ||||
| } | ||||
|  | ||||
| class _SimpleTapCallbacksComponent extends PositionComponent with TapCallbacks { | ||||
|   _SimpleTapCallbacksComponent({Vector2? size, List<Component>? children}) | ||||
|       : super(children: children, size: size); | ||||
|   _SimpleTapCallbacksComponent({super.size}); | ||||
| } | ||||
|  | ||||
| class _TappableComponent extends PositionComponent with Tappable { | ||||
|  | ||||
| @ -96,7 +96,7 @@ class _MyApp extends StatelessWidget { | ||||
| class _MyContainer extends StatefulWidget { | ||||
|   final List<String> events; | ||||
|  | ||||
|   const _MyContainer(this.events, {Key? key}) : super(key: key); | ||||
|   const _MyContainer(this.events); | ||||
|  | ||||
|   @override | ||||
|   State<_MyContainer> createState() => _MyContainerState(); | ||||
|  | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user
	 Lukas Klingsbo
					Lukas Klingsbo