Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:


env:
FLUTTER_MIN_VERSION: '3.44.0'
FLUTTER_MIN_VERSION: '3.47.0'

jobs:
# BEGIN LINTING STAGE
Expand All @@ -29,10 +29,10 @@ jobs:
with:
flutter-version: ${{env.FLUTTER_MIN_VERSION}}
- uses: bluefireteam/melos-action@v3
# flame_3d always requires the latest stable, since flutter_gpu is still
# unstable, so it is only analyzed in the analyze-latest job.
- name: "Analyze with lowest supported version"
run: melos exec --ignore="flame_3d*" -- dart analyze --fatal-infos .
uses: invertase/github-action-dart-analyzer@v3
with:
fatal-infos: true

analyze-latest:
runs-on: ubuntu-latest
Expand Down
14 changes: 6 additions & 8 deletions doc/flame/examples/lib/anchor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:flame/events.dart';
import 'package:flame/game.dart';
import 'package:flame/palette.dart';

class AnchorGame extends FlameGame {
class AnchorGame() extends FlameGame {
final _parentAnchorText = TextComponent(position: Vector2.all(5));
final _childAnchorText = TextComponent(position: Vector2(5, 30));

Expand Down Expand Up @@ -50,13 +50,11 @@ class AnchorGame extends FlameGame {
}
}

class _AnchoredRectangle extends RectangleComponent with TapCallbacks {
_AnchoredRectangle({
super.position,
super.size,
super.paint,
});

class _AnchoredRectangle({
super.position,
super.size,
super.paint,
}) extends RectangleComponent with TapCallbacks {
@override
void onTapDown(TapDownEvent event) {
var index = Anchor.values.indexOf(anchor) + 1;
Expand Down
2 changes: 1 addition & 1 deletion doc/flame/examples/lib/anchor_by_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:doc_flame_examples/flower.dart';
import 'package:flame/effects.dart';
import 'package:flame/game.dart';

class AnchorByEffectGame extends FlameGame {
class AnchorByEffectGame() extends FlameGame {
bool reset = false;

@override
Expand Down
2 changes: 1 addition & 1 deletion doc/flame/examples/lib/anchor_to_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flame/components.dart';
import 'package:flame/effects.dart';
import 'package:flame/game.dart';

class AnchorToEffectGame extends FlameGame {
class AnchorToEffectGame() extends FlameGame {
@override
Future<void> onLoad() async {
final flower = Flower(
Expand Down
8 changes: 5 additions & 3 deletions doc/flame/examples/lib/collision_detection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:flame/effects.dart';
import 'package:flame/game.dart';
import 'package:material_ui/material_ui.dart' hide Image;

class CollisionDetectionGame extends FlameGame with HasCollisionDetection {
class CollisionDetectionGame() extends FlameGame with HasCollisionDetection {
@override
Future<void> onLoad() async {
final emberPlayer = EmberPlayer(
Expand All @@ -30,12 +30,14 @@ class CollisionDetectionGame extends FlameGame with HasCollisionDetection {
}
}

class RectangleCollidable extends PositionComponent with CollisionCallbacks {
class RectangleCollidable(Vector2 position)
extends PositionComponent
with CollisionCallbacks {
final _collisionStartColor = Colors.amber;
final _defaultColor = Colors.cyan;
late ShapeHitbox hitbox;

RectangleCollidable(Vector2 position)
this
: super(
position: position,
size: Vector2.all(50),
Expand Down
2 changes: 1 addition & 1 deletion doc/flame/examples/lib/color_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:flame/effects.dart';
import 'package:flame/game.dart';
import 'package:flutter/animation.dart';

class ColorEffectExample extends FlameGame {
class ColorEffectExample() extends FlameGame {
bool reset = false;

@override
Expand Down
2 changes: 1 addition & 1 deletion doc/flame/examples/lib/decorator_blur.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:doc_flame_examples/flower.dart';
import 'package:flame/game.dart';
import 'package:flame/rendering.dart';

class DecoratorBlurGame extends FlameGame {
class DecoratorBlurGame() extends FlameGame {
@override
Future<void> onLoad() async {
var step = 0;
Expand Down
2 changes: 1 addition & 1 deletion doc/flame/examples/lib/decorator_grayscale.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:doc_flame_examples/flower.dart';
import 'package:flame/game.dart';
import 'package:flame/rendering.dart';

class DecoratorGrayscaleGame extends FlameGame {
class DecoratorGrayscaleGame() extends FlameGame {
@override
Future<void> onLoad() async {
var step = 0;
Expand Down
2 changes: 1 addition & 1 deletion doc/flame/examples/lib/decorator_hue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:doc_flame_examples/flower.dart';
import 'package:flame/game.dart';
import 'package:flame/rendering.dart';

class DecoratorHueGame extends FlameGame {
class DecoratorHueGame() extends FlameGame {
@override
Future<void> onLoad() async {
var step = 0;
Expand Down
2 changes: 1 addition & 1 deletion doc/flame/examples/lib/decorator_rotate3d.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:doc_flame_examples/flower.dart';
import 'package:flame/game.dart';
import 'package:flame/rendering.dart';

class DecoratorRotate3DGame extends FlameGame {
class DecoratorRotate3DGame() extends FlameGame {
@override
Future<void> onLoad() async {
var step = 0;
Expand Down
4 changes: 2 additions & 2 deletions doc/flame/examples/lib/decorator_shadow3d.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:flame/components.dart';
import 'package:flame/game.dart';
import 'package:flame/rendering.dart';

class DecoratorShadowGame extends FlameGame {
class DecoratorShadowGame() extends FlameGame {
@override
Color backgroundColor() => const Color(0xFFC7C7C7);

Expand Down Expand Up @@ -52,7 +52,7 @@ class DecoratorShadowGame extends FlameGame {
}
}

class Grid extends Component {
class Grid() extends Component {
final paint = Paint()
..color = const Color(0xffa9a9a9)
..style = PaintingStyle.stroke
Expand Down
2 changes: 1 addition & 1 deletion doc/flame/examples/lib/decorator_tint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:doc_flame_examples/flower.dart';
import 'package:flame/game.dart';
import 'package:flame/rendering.dart';

class DecoratorTintGame extends FlameGame {
class DecoratorTintGame() extends FlameGame {
@override
Future<void> onLoad() async {
var step = 0;
Expand Down
37 changes: 17 additions & 20 deletions doc/flame/examples/lib/drag_events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:flame/game.dart';
import 'package:flame/geometry.dart';
import 'package:flutter/rendering.dart';

class DragEventsGame extends FlameGame {
class DragEventsGame() extends FlameGame {
@override
Future<void> onLoad() async {
addAll([
Expand Down Expand Up @@ -49,8 +49,8 @@ class DragEventsGame extends FlameGame {

/// This component is the pink-ish rectangle in the center of the game window.
/// It uses the [DragCallbacks] mixin in order to receive drag events.
class DragTarget extends PositionComponent with DragCallbacks {
DragTarget() : super(anchor: Anchor.center);
class DragTarget() extends PositionComponent with DragCallbacks {
this : super(anchor: Anchor.center);

final _rectPaint = Paint()..color = const Color(0x88AC54BF);

Expand Down Expand Up @@ -99,27 +99,25 @@ class DragTarget extends PositionComponent with DragCallbacks {
}
}

class Trail extends Component {
Trail(Vector2 origin)
: _paths = [Path()..moveTo(origin.x, origin.y)],
_opacities = [1],
_lastPoint = origin.clone(),
class Trail(Vector2 origin) extends Component {
this
: _opacities = [1],
_color = HSLColor.fromAHSL(
1,
random.nextDouble() * 360,
1,
0.8,
).toColor();

final List<Path> _paths;
final List<Path> _paths = [Path()..moveTo(origin.x, origin.y)];
final List<double> _opacities;
Color _color;
late final _linePaint = Paint()..style = PaintingStyle.stroke;
late final _circlePaint = Paint()..color = _color;
bool _released = false;
double _timer = 0;
final _vanishInterval = 0.03;
final Vector2 _lastPoint;
final Vector2 _lastPoint = origin.clone();

static final random = Random();
static const lineWidth = 10.0;
Expand Down Expand Up @@ -182,15 +180,15 @@ class Trail extends Component {
}
}

class Star extends PositionComponent with DragCallbacks {
Star({
required int n,
required double radius1,
required double radius2,
required double sharpness,
required this.color,
super.position,
}) {
class Star({
required int n,
required double radius1,
required double radius2,
required double sharpness,
required final Color color,
super.position,
}) extends PositionComponent with DragCallbacks {
this {
_path = Path()..moveTo(radius1, 0);
for (var i = 0; i < n; i++) {
final p1 = Vector2(radius2, 0)..rotate(tau / n * (i + sharpness));
Expand All @@ -201,7 +199,6 @@ class Star extends PositionComponent with DragCallbacks {
_path.close();
}

final Color color;
final Paint _paint = Paint();
final Paint _borderPaint = Paint()
..color = const Color(0xFFffffff)
Expand Down
14 changes: 5 additions & 9 deletions doc/flame/examples/lib/ember.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@ import 'package:flame/components.dart';
import 'package:flame/events.dart';
import 'package:flame/flame.dart';

class EmberPlayer extends SpriteAnimationComponent with TapCallbacks {
EmberPlayer({
required super.size,
super.position,
this._onTap,
});

class EmberPlayer({
required super.size,
super.position,
final void Function(EmberPlayer player)? _onTap,
}) extends SpriteAnimationComponent with TapCallbacks {
Vector2 velocity = Vector2(0, 0);
final void Function(EmberPlayer player)? _onTap;

@override
Future<void> onLoad() async {
animation = SpriteAnimation.fromFrameData(
Expand Down
25 changes: 14 additions & 11 deletions doc/flame/examples/lib/flower.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ import 'package:flame/events.dart';
import 'package:flame/geometry.dart';
import 'package:flame/rendering.dart';

enum FlowerPaint { paintId1, paintId2, paintId3, paintId4, paintId5 }
enum FlowerPaint() {
paintId1,
paintId2,
paintId3,
paintId4,
paintId5,
}

class Flower extends PositionComponent
with TapCallbacks, HasPaint<FlowerPaint> {
Flower({
required double size,
this._onTap,
Decorator? decorator,
super.position,
}) : super(size: Vector2.all(size), anchor: Anchor.center) {
class Flower({
required double size,
final void Function(Flower flower)? _onTap,
Decorator? decorator,
super.position,
}) extends PositionComponent with TapCallbacks, HasPaint<FlowerPaint> {
this : super(size: Vector2.all(size), anchor: Anchor.center) {
this.decorator.addLast(decorator);
final radius = size * 0.38;
_paths.add(_makePath(radius * 1.4, 6, -0.05, 0.8));
Expand All @@ -31,8 +36,6 @@ class Flower extends PositionComponent
}

final List<Path> _paths = [];
final void Function(Flower flower)? _onTap;

Path _makePath(double radius, int n, double sharpness, double f) {
final radius2 = radius * f;
final p0 = Vector2(radius, 0)..rotate(0);
Expand Down
2 changes: 1 addition & 1 deletion doc/flame/examples/lib/glow_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:flame/game.dart';

import 'package:material_ui/material_ui.dart';

class GlowEffectExample extends FlameGame {
class GlowEffectExample() extends FlameGame {
@override
Future<void> onLoad() async {
final paint = Paint()..color = const Color(0xff39FF14);
Expand Down
2 changes: 1 addition & 1 deletion doc/flame/examples/lib/hue_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:flame/components.dart';
import 'package:flame/effects.dart';
import 'package:flame/game.dart';

class HueEffectExample extends FlameGame {
class HueEffectExample() extends FlameGame {
@override
Future<void> onLoad() async {
final ember = EmberPlayer(
Expand Down
10 changes: 3 additions & 7 deletions doc/flame/examples/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,9 @@ void main() {
}
}

class _IndexRoute extends StatelessWidget {
final String page;

const _IndexRoute({
required this.page,
});

class const _IndexRoute({
required final String page,
}) extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Directionality(
Expand Down
2 changes: 1 addition & 1 deletion doc/flame/examples/lib/move_along_path_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:doc_flame_examples/flower.dart';
import 'package:flame/effects.dart';
import 'package:flame/game.dart';

class MoveAlongPathEffectGame extends FlameGame {
class MoveAlongPathEffectGame() extends FlameGame {
bool reset = false;
@override
Future<void> onLoad() async {
Expand Down
2 changes: 1 addition & 1 deletion doc/flame/examples/lib/move_by_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:doc_flame_examples/flower.dart';
import 'package:flame/effects.dart';
import 'package:flame/game.dart';

class MoveByEffectGame extends FlameGame {
class MoveByEffectGame() extends FlameGame {
bool reset = false;
@override
Future<void> onLoad() async {
Expand Down
2 changes: 1 addition & 1 deletion doc/flame/examples/lib/move_to_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:doc_flame_examples/flower.dart';
import 'package:flame/effects.dart';
import 'package:flame/game.dart';

class MoveToEffectGame extends FlameGame {
class MoveToEffectGame() extends FlameGame {
bool reset = false;

@override
Expand Down
2 changes: 1 addition & 1 deletion doc/flame/examples/lib/opacity_by_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flame/components.dart';
import 'package:flame/effects.dart';
import 'package:flame/game.dart';

class OpacityByEffectGame extends FlameGame {
class OpacityByEffectGame() extends FlameGame {
bool reset = false;

@override
Expand Down
2 changes: 1 addition & 1 deletion doc/flame/examples/lib/opacity_effect_with_target.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flame/components.dart';
import 'package:flame/effects.dart';
import 'package:flame/game.dart';

class OpacityEffectWithTargetGame extends FlameGame {
class OpacityEffectWithTargetGame() extends FlameGame {
bool reset = false;

// This reference needs to be stored because every new instance of
Expand Down
Loading
Loading