mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-18 13:48:13 +08:00
Linting
This commit is contained in:
@@ -22,11 +22,7 @@ class MyGame extends Game with MultiTouchTapDetector {
|
||||
@override
|
||||
void onTapDown(int pointerId, TapDownDetails details) {
|
||||
_taps[pointerId] = Rect.fromLTWH(
|
||||
details.globalPosition.dx,
|
||||
details.globalPosition.dy,
|
||||
50,
|
||||
50
|
||||
);
|
||||
details.globalPosition.dx, details.globalPosition.dy, 50, 50);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -26,11 +26,7 @@ class MyGame extends Game with MultiTouchTapDetector, PanDetector {
|
||||
@override
|
||||
void onTapDown(int pointerId, TapDownDetails details) {
|
||||
_taps[pointerId] = Rect.fromLTWH(
|
||||
details.globalPosition.dx,
|
||||
details.globalPosition.dy,
|
||||
50,
|
||||
50
|
||||
);
|
||||
details.globalPosition.dx, details.globalPosition.dy, 50, 50);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -57,8 +53,10 @@ class MyGame extends Game with MultiTouchTapDetector, PanDetector {
|
||||
@override
|
||||
void onPanEnd(details) {
|
||||
_panRect = Rect.fromLTRB(
|
||||
_start.dx, _start.dy,
|
||||
_end.dx, _end.dy,
|
||||
_start.dx,
|
||||
_start.dy,
|
||||
_end.dx,
|
||||
_end.dy,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,31 +64,41 @@ class GestureDetector extends StatelessWidget {
|
||||
}) : assert(excludeFromSemantics != null),
|
||||
assert(dragStartBehavior != null),
|
||||
assert(() {
|
||||
final bool haveVerticalDrag = onVerticalDragStart != null || onVerticalDragUpdate != null || onVerticalDragEnd != null;
|
||||
final bool haveHorizontalDrag = onHorizontalDragStart != null || onHorizontalDragUpdate != null || onHorizontalDragEnd != null;
|
||||
final bool havePan = onPanStart != null || onPanUpdate != null || onPanEnd != null;
|
||||
final bool haveScale = onScaleStart != null || onScaleUpdate != null || onScaleEnd != null;
|
||||
final bool haveVerticalDrag = onVerticalDragStart != null ||
|
||||
onVerticalDragUpdate != null ||
|
||||
onVerticalDragEnd != null;
|
||||
final bool haveHorizontalDrag = onHorizontalDragStart != null ||
|
||||
onHorizontalDragUpdate != null ||
|
||||
onHorizontalDragEnd != null;
|
||||
final bool havePan =
|
||||
onPanStart != null || onPanUpdate != null || onPanEnd != null;
|
||||
final bool haveScale = onScaleStart != null ||
|
||||
onScaleUpdate != null ||
|
||||
onScaleEnd != null;
|
||||
|
||||
final bool haveTap = onTap != null || onTapCancel != null || onTapUp != null || onTapDown != null;
|
||||
final bool haveMultiTap = onMultiTap != null || onMultiTapCancel != null || onMultiTapUp != null || onMultiTapDown != null;
|
||||
final bool haveTap = onTap != null ||
|
||||
onTapCancel != null ||
|
||||
onTapUp != null ||
|
||||
onTapDown != null;
|
||||
final bool haveMultiTap = onMultiTap != null ||
|
||||
onMultiTapCancel != null ||
|
||||
onMultiTapUp != null ||
|
||||
onMultiTapDown != null;
|
||||
|
||||
if (havePan || haveScale) {
|
||||
if (havePan && haveScale) {
|
||||
throw FlutterError.fromParts(<DiagnosticsNode>[
|
||||
ErrorSummary('Incorrect GestureDetector arguments.'),
|
||||
ErrorDescription(
|
||||
'Having both a pan gesture recognizer and a scale gesture recognizer is redundant; scale is a superset of pan.'
|
||||
),
|
||||
'Having both a pan gesture recognizer and a scale gesture recognizer is redundant; scale is a superset of pan.'),
|
||||
ErrorHint('Just use the scale gesture recognizer.')
|
||||
]);
|
||||
}
|
||||
final String recognizer = havePan ? 'pan' : 'scale';
|
||||
if (haveVerticalDrag && haveHorizontalDrag) {
|
||||
throw FlutterError(
|
||||
'Incorrect GestureDetector arguments.\n'
|
||||
throw FlutterError('Incorrect GestureDetector arguments.\n'
|
||||
'Simultaneously having a vertical drag gesture recognizer, a horizontal drag gesture recognizer, and a $recognizer gesture recognizer '
|
||||
'will result in the $recognizer gesture recognizer being ignored, since the other two will catch all drags.'
|
||||
);
|
||||
'will result in the $recognizer gesture recognizer being ignored, since the other two will catch all drags.');
|
||||
}
|
||||
}
|
||||
if (haveTap || haveMultiTap) {
|
||||
@@ -96,8 +106,7 @@ class GestureDetector extends StatelessWidget {
|
||||
throw FlutterError.fromParts(<DiagnosticsNode>[
|
||||
ErrorSummary('Incorrect GestureDetector arguments.'),
|
||||
ErrorDescription(
|
||||
'Having both a tap gesture recognizer and a multi tap gesture recognizer is redundant.'
|
||||
),
|
||||
'Having both a tap gesture recognizer and a multi tap gesture recognizer is redundant.'),
|
||||
ErrorHint('Just use one of the recognizers.')
|
||||
]);
|
||||
}
|
||||
@@ -453,18 +462,18 @@ class GestureDetector extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Map<Type, GestureRecognizerFactory> gestures = <Type, GestureRecognizerFactory>{};
|
||||
final Map<Type, GestureRecognizerFactory> gestures =
|
||||
<Type, GestureRecognizerFactory>{};
|
||||
|
||||
if (
|
||||
onTapDown != null ||
|
||||
if (onTapDown != null ||
|
||||
onTapUp != null ||
|
||||
onTap != null ||
|
||||
onTapCancel != null ||
|
||||
onSecondaryTapDown != null ||
|
||||
onSecondaryTapUp != null ||
|
||||
onSecondaryTapCancel != null
|
||||
) {
|
||||
gestures[TapGestureRecognizer] = GestureRecognizerFactoryWithHandlers<TapGestureRecognizer>(
|
||||
onSecondaryTapCancel != null) {
|
||||
gestures[TapGestureRecognizer] =
|
||||
GestureRecognizerFactoryWithHandlers<TapGestureRecognizer>(
|
||||
() => TapGestureRecognizer(debugOwner: this),
|
||||
(TapGestureRecognizer instance) {
|
||||
instance
|
||||
@@ -480,7 +489,8 @@ class GestureDetector extends StatelessWidget {
|
||||
}
|
||||
|
||||
if (onDoubleTap != null) {
|
||||
gestures[DoubleTapGestureRecognizer] = GestureRecognizerFactoryWithHandlers<DoubleTapGestureRecognizer>(
|
||||
gestures[DoubleTapGestureRecognizer] =
|
||||
GestureRecognizerFactoryWithHandlers<DoubleTapGestureRecognizer>(
|
||||
() => DoubleTapGestureRecognizer(debugOwner: this),
|
||||
(DoubleTapGestureRecognizer instance) {
|
||||
instance.onDoubleTap = onDoubleTap;
|
||||
@@ -493,7 +503,8 @@ class GestureDetector extends StatelessWidget {
|
||||
onLongPressStart != null ||
|
||||
onLongPressMoveUpdate != null ||
|
||||
onLongPressEnd != null) {
|
||||
gestures[LongPressGestureRecognizer] = GestureRecognizerFactoryWithHandlers<LongPressGestureRecognizer>(
|
||||
gestures[LongPressGestureRecognizer] =
|
||||
GestureRecognizerFactoryWithHandlers<LongPressGestureRecognizer>(
|
||||
() => LongPressGestureRecognizer(debugOwner: this),
|
||||
(LongPressGestureRecognizer instance) {
|
||||
instance
|
||||
@@ -511,7 +522,8 @@ class GestureDetector extends StatelessWidget {
|
||||
onVerticalDragUpdate != null ||
|
||||
onVerticalDragEnd != null ||
|
||||
onVerticalDragCancel != null) {
|
||||
gestures[VerticalDragGestureRecognizer] = GestureRecognizerFactoryWithHandlers<VerticalDragGestureRecognizer>(
|
||||
gestures[VerticalDragGestureRecognizer] =
|
||||
GestureRecognizerFactoryWithHandlers<VerticalDragGestureRecognizer>(
|
||||
() => VerticalDragGestureRecognizer(debugOwner: this),
|
||||
(VerticalDragGestureRecognizer instance) {
|
||||
instance
|
||||
@@ -530,7 +542,8 @@ class GestureDetector extends StatelessWidget {
|
||||
onHorizontalDragUpdate != null ||
|
||||
onHorizontalDragEnd != null ||
|
||||
onHorizontalDragCancel != null) {
|
||||
gestures[HorizontalDragGestureRecognizer] = GestureRecognizerFactoryWithHandlers<HorizontalDragGestureRecognizer>(
|
||||
gestures[HorizontalDragGestureRecognizer] =
|
||||
GestureRecognizerFactoryWithHandlers<HorizontalDragGestureRecognizer>(
|
||||
() => HorizontalDragGestureRecognizer(debugOwner: this),
|
||||
(HorizontalDragGestureRecognizer instance) {
|
||||
instance
|
||||
@@ -549,7 +562,8 @@ class GestureDetector extends StatelessWidget {
|
||||
onPanUpdate != null ||
|
||||
onPanEnd != null ||
|
||||
onPanCancel != null) {
|
||||
gestures[PanGestureRecognizer] = GestureRecognizerFactoryWithHandlers<PanGestureRecognizer>(
|
||||
gestures[PanGestureRecognizer] =
|
||||
GestureRecognizerFactoryWithHandlers<PanGestureRecognizer>(
|
||||
() => PanGestureRecognizer(debugOwner: this),
|
||||
(PanGestureRecognizer instance) {
|
||||
instance
|
||||
@@ -564,7 +578,8 @@ class GestureDetector extends StatelessWidget {
|
||||
}
|
||||
|
||||
if (onScaleStart != null || onScaleUpdate != null || onScaleEnd != null) {
|
||||
gestures[ScaleGestureRecognizer] = GestureRecognizerFactoryWithHandlers<ScaleGestureRecognizer>(
|
||||
gestures[ScaleGestureRecognizer] =
|
||||
GestureRecognizerFactoryWithHandlers<ScaleGestureRecognizer>(
|
||||
() => ScaleGestureRecognizer(debugOwner: this),
|
||||
(ScaleGestureRecognizer instance) {
|
||||
instance
|
||||
@@ -579,7 +594,8 @@ class GestureDetector extends StatelessWidget {
|
||||
onForcePressPeak != null ||
|
||||
onForcePressUpdate != null ||
|
||||
onForcePressEnd != null) {
|
||||
gestures[ForcePressGestureRecognizer] = GestureRecognizerFactoryWithHandlers<ForcePressGestureRecognizer>(
|
||||
gestures[ForcePressGestureRecognizer] =
|
||||
GestureRecognizerFactoryWithHandlers<ForcePressGestureRecognizer>(
|
||||
() => ForcePressGestureRecognizer(debugOwner: this),
|
||||
(ForcePressGestureRecognizer instance) {
|
||||
instance
|
||||
@@ -591,13 +607,12 @@ class GestureDetector extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
onMultiTapDown != null ||
|
||||
if (onMultiTapDown != null ||
|
||||
onMultiTapUp != null ||
|
||||
onMultiTap != null ||
|
||||
onMultiTapCancel != null
|
||||
) {
|
||||
gestures[MultiTapGestureRecognizer] = GestureRecognizerFactoryWithHandlers<MultiTapGestureRecognizer>(
|
||||
onMultiTapCancel != null) {
|
||||
gestures[MultiTapGestureRecognizer] =
|
||||
GestureRecognizerFactoryWithHandlers<MultiTapGestureRecognizer>(
|
||||
() => MultiTapGestureRecognizer(debugOwner: this),
|
||||
(MultiTapGestureRecognizer instance) {
|
||||
instance
|
||||
@@ -616,9 +631,11 @@ class GestureDetector extends StatelessWidget {
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
properties.add(EnumProperty<DragStartBehavior>('startBehavior', dragStartBehavior));
|
||||
properties.add(
|
||||
EnumProperty<DragStartBehavior>('startBehavior', dragStartBehavior));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,8 @@ Widget _applyGesturesDetectors(Game game, Widget child) {
|
||||
return flame_detector.GestureDetector(
|
||||
// Taps
|
||||
onTap: game is TapDetector ? () => (game as TapDetector).onTap() : null,
|
||||
onTapCancel: game is TapDetector
|
||||
? () => (game as TapDetector).onTapCancel()
|
||||
: null,
|
||||
onTapCancel:
|
||||
game is TapDetector ? () => (game as TapDetector).onTapCancel() : null,
|
||||
onTapDown: game is TapDetector
|
||||
? (TapDownDetails d) => (game as TapDetector).onTapDown(d)
|
||||
: null,
|
||||
@@ -33,15 +32,20 @@ Widget _applyGesturesDetectors(Game game, Widget child) {
|
||||
: null,
|
||||
|
||||
// MultiTaps
|
||||
onMultiTap: game is MultiTouchTapDetector ? (int pointerId) => (game as MultiTouchTapDetector).onTap(pointerId) : null,
|
||||
onMultiTap: game is MultiTouchTapDetector
|
||||
? (int pointerId) => (game as MultiTouchTapDetector).onTap(pointerId)
|
||||
: null,
|
||||
onMultiTapCancel: game is MultiTouchTapDetector
|
||||
? (int pointerId) => (game as MultiTouchTapDetector).onTapCancel(pointerId)
|
||||
? (int pointerId) =>
|
||||
(game as MultiTouchTapDetector).onTapCancel(pointerId)
|
||||
: null,
|
||||
onMultiTapDown: game is MultiTouchTapDetector
|
||||
? (int pointerId, TapDownDetails d) => (game as MultiTouchTapDetector).onTapDown(pointerId, d)
|
||||
? (int pointerId, TapDownDetails d) =>
|
||||
(game as MultiTouchTapDetector).onTapDown(pointerId, d)
|
||||
: null,
|
||||
onMultiTapUp: game is MultiTouchTapDetector
|
||||
? (int pointerId, TapUpDetails d) => (game as MultiTouchTapDetector).onTapUp(pointerId, d)
|
||||
? (int pointerId, TapUpDetails d) =>
|
||||
(game as MultiTouchTapDetector).onTapUp(pointerId, d)
|
||||
: null,
|
||||
|
||||
// Secondary taps
|
||||
@@ -50,8 +54,7 @@ Widget _applyGesturesDetectors(Game game, Widget child) {
|
||||
(game as SecondaryTapDetector).onSecondaryTapDown(d)
|
||||
: null,
|
||||
onSecondaryTapUp: game is SecondaryTapDetector
|
||||
? (TapUpDetails d) =>
|
||||
(game as SecondaryTapDetector).onSecondaryTapUp(d)
|
||||
? (TapUpDetails d) => (game as SecondaryTapDetector).onSecondaryTapUp(d)
|
||||
: null,
|
||||
onSecondaryTapCancel: game is SecondaryTapDetector
|
||||
? () => (game as SecondaryTapDetector).onSecondaryTapCancel()
|
||||
@@ -155,9 +158,8 @@ Widget _applyGesturesDetectors(Game game, Widget child) {
|
||||
onPanEnd: game is PanDetector
|
||||
? (DragEndDetails d) => (game as PanDetector).onPanEnd(d)
|
||||
: null,
|
||||
onPanCancel: game is PanDetector
|
||||
? () => (game as PanDetector).onPanCancel()
|
||||
: null,
|
||||
onPanCancel:
|
||||
game is PanDetector ? () => (game as PanDetector).onPanCancel() : null,
|
||||
|
||||
// Scales
|
||||
onScaleStart: game is ScaleDetector
|
||||
|
||||
Reference in New Issue
Block a user