New linter rules (#676)

This commit is contained in:
Luan Nico
2021-02-23 12:16:23 -05:00
committed by GitHub
parent 6329a12150
commit 9c38c9bd04
103 changed files with 606 additions and 561 deletions

View File

@@ -21,8 +21,10 @@ class Palette {
static const PaletteEntry blue = PaletteEntry(Color(0xFF0000FF));
}
class Square extends PositionComponent with HasGameRef<MyGame> {
static const SPEED = 0.25;
class Square extends PositionComponent {
static const speed = 0.25;
static const squareSize = 128.0;
static Paint white = Palette.white.paint;
static Paint red = Palette.red.paint;
static Paint blue = Palette.blue.paint;
@@ -36,23 +38,21 @@ class Square extends PositionComponent with HasGameRef<MyGame> {
c.drawRect(Rect.fromLTWH(width / 2, height / 2, 3, 3), blue);
}
@override
void update(double dt) {
super.update(dt);
angle += SPEED * dt;
angle += speed * t;
angle %= 2 * math.pi;
}
@override
void onMount() {
super.onMount();
size = Vector2.all(gameRef.squareSize);
size = Vector2.all(squareSize);
anchor = Anchor.center;
}
}
class MyGame extends BaseGame with DoubleTapDetector, TapDetector {
final double squareSize = 128;
bool running = true;
MyGame() {
@@ -62,19 +62,19 @@ class MyGame extends BaseGame with DoubleTapDetector, TapDetector {
}
@override
void onTapUp(details) {
void onTapUp(TapUpDetails details) {
final touchArea = Rect.fromCenter(
center: details.localPosition,
width: 20,
height: 20,
);
bool handled = false;
components.forEach((c) {
final handled = components.any((c) {
if (c is PositionComponent && c.toRect().overlaps(touchArea)) {
handled = true;
remove(c);
return true;
}
return false;
});
if (!handled) {