Skip to content

Commit bae5838

Browse files
authored
chore: Deprecate old detectors fully replaced with callbacks (#3935)
Deprecate old detectors fully replaced with callbacks. These all have 1:1 callback equivalents. Part of our event system design doc proposal.
1 parent f21c5a8 commit bae5838

5 files changed

Lines changed: 12 additions & 10 deletions

File tree

examples/lib/stories/rendering/nine_tile_box_custom_grid_example.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import 'package:flame/components.dart';
22
import 'package:flame/events.dart';
33
import 'package:flame/game.dart';
4-
import 'package:flame/input.dart';
54

65
class NineTileBoxCustomGridExample extends FlameGame
7-
with TapCallbacks, DoubleTapDetector {
6+
with TapCallbacks, DoubleTapCallbacks {
87
static const String description = '''
98
If you want to create a background for something that can stretch you can
109
use the `NineTileBox` which is showcased here. In this example a custom
@@ -41,7 +40,7 @@ class NineTileBoxCustomGridExample extends FlameGame
4140
}
4241

4342
@override
44-
void onDoubleTap() {
43+
void onDoubleTapDown(_) {
4544
nineTileBoxComponent.scale.scale(0.8);
4645
}
4746
}

examples/lib/stories/rendering/nine_tile_box_example.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'package:flame/events.dart';
33
import 'package:flame/game.dart';
44

55
class NineTileBoxExample extends FlameGame
6-
with TapCallbacks, DoubleTapDetector {
6+
with TapCallbacks, DoubleTapCallbacks {
77
static const String description = '''
88
If you want to create a background for something that can stretch you can
99
use the `NineTileBox` which is showcased here.\n\n
@@ -33,7 +33,7 @@ class NineTileBoxExample extends FlameGame
3333
}
3434

3535
@override
36-
void onDoubleTap() {
36+
void onDoubleTapDown(_) {
3737
nineTileBoxComponent.scale.scale(0.8);
3838
}
3939
}

examples/lib/stories/system/pause_resume_example.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import 'package:flame/components.dart';
22
import 'package:flame/events.dart';
33
import 'package:flame/game.dart';
4-
import 'package:flame/input.dart';
54

65
class PauseResumeExample extends FlameGame
7-
with TapCallbacks, DoubleTapDetector {
6+
with TapCallbacks, DoubleTapCallbacks {
87
static const description = '''
98
Demonstrate how to use the pause and resume engine methods and paused
109
attribute.
@@ -47,7 +46,7 @@ class PauseResumeExample extends FlameGame
4746
}
4847

4948
@override
50-
void onDoubleTap() {
49+
void onDoubleTapDown(_) {
5150
paused = !paused;
5251
}
5352
}

examples/lib/stories/utils/timer_component_example.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:flame/game.dart';
44
import 'package:flutter/material.dart';
55

66
class TimerComponentExample extends FlameGame
7-
with TapCallbacks, DoubleTapDetector {
7+
with TapCallbacks, DoubleTapCallbacks {
88
static const String description = '''
99
This examples showcases the `TimerComponent`.\n\n
1010
Tap to start a timer that lives for one second and double tap to start
@@ -22,7 +22,7 @@ class TimerComponentExample extends FlameGame
2222
}
2323

2424
@override
25-
void onDoubleTap() {
25+
void onDoubleTapDown(_) {
2626
doubleTapComponent?.removeFromParent();
2727
doubleTapComponent = RenderedTimeComponent(5, yOffset: 180);
2828
add(doubleTapComponent!);

packages/flame/lib/src/gestures/detectors.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ mixin TapDetector on Game {
1818
}
1919
}
2020

21+
@Deprecated('Use SecondaryTapCallbacks instead')
2122
mixin SecondaryTapDetector on Game {
2223
void onSecondaryTapDown(TapDownInfo info) {}
2324
void onSecondaryTapUp(TapUpInfo info) {}
@@ -32,6 +33,7 @@ mixin SecondaryTapDetector on Game {
3233
}
3334
}
3435

36+
@Deprecated('Use TertiaryTapCallbacks instead')
3537
mixin TertiaryTapDetector on Game {
3638
void onTertiaryTapDown(TapDownInfo info) {}
3739
void onTertiaryTapUp(TapUpInfo info) {}
@@ -46,6 +48,7 @@ mixin TertiaryTapDetector on Game {
4648
}
4749
}
4850

51+
@Deprecated('Use DoubleTapCallbacks instead')
4952
mixin DoubleTapDetector on Game {
5053
void onDoubleTap() {}
5154
void onDoubleTapCancel() {}
@@ -56,6 +59,7 @@ mixin DoubleTapDetector on Game {
5659
}
5760
}
5861

62+
@Deprecated('Use LongPressCallbacks instead')
5963
mixin LongPressDetector on Game {
6064
void onLongPress() {}
6165
void onLongPressStart(LongPressStartInfo info) {}

0 commit comments

Comments
 (0)