This commit is contained in:
Erick Zanardo
2020-05-13 12:03:06 -03:00
parent b901063d63
commit aa1ffced6f
4 changed files with 252 additions and 239 deletions

View File

@@ -22,11 +22,7 @@ class MyGame extends Game with MultiTouchTapDetector {
@override @override
void onTapDown(int pointerId, TapDownDetails details) { void onTapDown(int pointerId, TapDownDetails details) {
_taps[pointerId] = Rect.fromLTWH( _taps[pointerId] = Rect.fromLTWH(
details.globalPosition.dx, details.globalPosition.dx, details.globalPosition.dy, 50, 50);
details.globalPosition.dy,
50,
50
);
} }
@override @override

View File

@@ -26,11 +26,7 @@ class MyGame extends Game with MultiTouchTapDetector, PanDetector {
@override @override
void onTapDown(int pointerId, TapDownDetails details) { void onTapDown(int pointerId, TapDownDetails details) {
_taps[pointerId] = Rect.fromLTWH( _taps[pointerId] = Rect.fromLTWH(
details.globalPosition.dx, details.globalPosition.dx, details.globalPosition.dy, 50, 50);
details.globalPosition.dy,
50,
50
);
} }
@override @override
@@ -57,8 +53,10 @@ class MyGame extends Game with MultiTouchTapDetector, PanDetector {
@override @override
void onPanEnd(details) { void onPanEnd(details) {
_panRect = Rect.fromLTRB( _panRect = Rect.fromLTRB(
_start.dx, _start.dy, _start.dx,
_end.dx, _end.dy, _start.dy,
_end.dx,
_end.dy,
); );
} }

View File

@@ -61,51 +61,60 @@ class GestureDetector extends StatelessWidget {
this.behavior, this.behavior,
this.excludeFromSemantics = false, this.excludeFromSemantics = false,
this.dragStartBehavior = DragStartBehavior.start, this.dragStartBehavior = DragStartBehavior.start,
}) : assert(excludeFromSemantics != null), }) : assert(excludeFromSemantics != null),
assert(dragStartBehavior != null), assert(dragStartBehavior != null),
assert(() { assert(() {
final bool haveVerticalDrag = onVerticalDragStart != null || onVerticalDragUpdate != null || onVerticalDragEnd != null; final bool haveVerticalDrag = onVerticalDragStart != null ||
final bool haveHorizontalDrag = onHorizontalDragStart != null || onHorizontalDragUpdate != null || onHorizontalDragEnd != null; onVerticalDragUpdate != null ||
final bool havePan = onPanStart != null || onPanUpdate != null || onPanEnd != null; onVerticalDragEnd != null;
final bool haveScale = onScaleStart != null || onScaleUpdate != null || onScaleEnd != 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 haveTap = onTap != null ||
final bool haveMultiTap = onMultiTap != null || onMultiTapCancel != null || onMultiTapUp != null || onMultiTapDown != null; onTapCancel != null ||
onTapUp != null ||
onTapDown != null;
final bool haveMultiTap = onMultiTap != null ||
onMultiTapCancel != null ||
onMultiTapUp != null ||
onMultiTapDown != null;
if (havePan || haveScale) { if (havePan || haveScale) {
if (havePan && haveScale) { if (havePan && haveScale) {
throw FlutterError.fromParts(<DiagnosticsNode>[ throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary('Incorrect GestureDetector arguments.'), ErrorSummary('Incorrect GestureDetector arguments.'),
ErrorDescription( 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.')
ErrorHint('Just use the scale gesture recognizer.') ]);
]); }
} final String recognizer = havePan ? 'pan' : 'scale';
final String recognizer = havePan ? 'pan' : 'scale'; if (haveVerticalDrag && haveHorizontalDrag) {
if (haveVerticalDrag && haveHorizontalDrag) { throw FlutterError('Incorrect GestureDetector arguments.\n'
throw FlutterError( 'Simultaneously having a vertical drag gesture recognizer, a horizontal drag gesture recognizer, and a $recognizer gesture recognizer '
'Incorrect GestureDetector arguments.\n' 'will result in the $recognizer gesture recognizer being ignored, since the other two will catch all drags.');
'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.' }
); if (haveTap || haveMultiTap) {
} if (haveTap && haveMultiTap) {
} throw FlutterError.fromParts(<DiagnosticsNode>[
if (haveTap || haveMultiTap) { ErrorSummary('Incorrect GestureDetector arguments.'),
if (haveTap && haveMultiTap) { ErrorDescription(
throw FlutterError.fromParts(<DiagnosticsNode>[ 'Having both a tap gesture recognizer and a multi tap gesture recognizer is redundant.'),
ErrorSummary('Incorrect GestureDetector arguments.'), ErrorHint('Just use one of the recognizers.')
ErrorDescription( ]);
'Having both a tap gesture recognizer and a multi tap gesture recognizer is redundant.' }
), }
ErrorHint('Just use one of the recognizers.')
]);
}
}
return true; return true;
}()), }()),
super(key: key); super(key: key);
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
/// ///
@@ -453,18 +462,18 @@ class GestureDetector extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final Map<Type, GestureRecognizerFactory> gestures = <Type, GestureRecognizerFactory>{}; final Map<Type, GestureRecognizerFactory> gestures =
<Type, GestureRecognizerFactory>{};
if ( if (onTapDown != null ||
onTapDown != null || onTapUp != null ||
onTapUp != null || onTap != null ||
onTap != null || onTapCancel != null ||
onTapCancel != null || onSecondaryTapDown != null ||
onSecondaryTapDown != null || onSecondaryTapUp != null ||
onSecondaryTapUp != null || onSecondaryTapCancel != null) {
onSecondaryTapCancel != null gestures[TapGestureRecognizer] =
) { GestureRecognizerFactoryWithHandlers<TapGestureRecognizer>(
gestures[TapGestureRecognizer] = GestureRecognizerFactoryWithHandlers<TapGestureRecognizer>(
() => TapGestureRecognizer(debugOwner: this), () => TapGestureRecognizer(debugOwner: this),
(TapGestureRecognizer instance) { (TapGestureRecognizer instance) {
instance instance
@@ -480,7 +489,8 @@ class GestureDetector extends StatelessWidget {
} }
if (onDoubleTap != null) { if (onDoubleTap != null) {
gestures[DoubleTapGestureRecognizer] = GestureRecognizerFactoryWithHandlers<DoubleTapGestureRecognizer>( gestures[DoubleTapGestureRecognizer] =
GestureRecognizerFactoryWithHandlers<DoubleTapGestureRecognizer>(
() => DoubleTapGestureRecognizer(debugOwner: this), () => DoubleTapGestureRecognizer(debugOwner: this),
(DoubleTapGestureRecognizer instance) { (DoubleTapGestureRecognizer instance) {
instance.onDoubleTap = onDoubleTap; instance.onDoubleTap = onDoubleTap;
@@ -493,14 +503,15 @@ class GestureDetector extends StatelessWidget {
onLongPressStart != null || onLongPressStart != null ||
onLongPressMoveUpdate != null || onLongPressMoveUpdate != null ||
onLongPressEnd != null) { onLongPressEnd != null) {
gestures[LongPressGestureRecognizer] = GestureRecognizerFactoryWithHandlers<LongPressGestureRecognizer>( gestures[LongPressGestureRecognizer] =
GestureRecognizerFactoryWithHandlers<LongPressGestureRecognizer>(
() => LongPressGestureRecognizer(debugOwner: this), () => LongPressGestureRecognizer(debugOwner: this),
(LongPressGestureRecognizer instance) { (LongPressGestureRecognizer instance) {
instance instance
..onLongPress = onLongPress ..onLongPress = onLongPress
..onLongPressStart = onLongPressStart ..onLongPressStart = onLongPressStart
..onLongPressMoveUpdate = onLongPressMoveUpdate ..onLongPressMoveUpdate = onLongPressMoveUpdate
..onLongPressEnd =onLongPressEnd ..onLongPressEnd = onLongPressEnd
..onLongPressUp = onLongPressUp; ..onLongPressUp = onLongPressUp;
}, },
); );
@@ -511,7 +522,8 @@ class GestureDetector extends StatelessWidget {
onVerticalDragUpdate != null || onVerticalDragUpdate != null ||
onVerticalDragEnd != null || onVerticalDragEnd != null ||
onVerticalDragCancel != null) { onVerticalDragCancel != null) {
gestures[VerticalDragGestureRecognizer] = GestureRecognizerFactoryWithHandlers<VerticalDragGestureRecognizer>( gestures[VerticalDragGestureRecognizer] =
GestureRecognizerFactoryWithHandlers<VerticalDragGestureRecognizer>(
() => VerticalDragGestureRecognizer(debugOwner: this), () => VerticalDragGestureRecognizer(debugOwner: this),
(VerticalDragGestureRecognizer instance) { (VerticalDragGestureRecognizer instance) {
instance instance
@@ -530,7 +542,8 @@ class GestureDetector extends StatelessWidget {
onHorizontalDragUpdate != null || onHorizontalDragUpdate != null ||
onHorizontalDragEnd != null || onHorizontalDragEnd != null ||
onHorizontalDragCancel != null) { onHorizontalDragCancel != null) {
gestures[HorizontalDragGestureRecognizer] = GestureRecognizerFactoryWithHandlers<HorizontalDragGestureRecognizer>( gestures[HorizontalDragGestureRecognizer] =
GestureRecognizerFactoryWithHandlers<HorizontalDragGestureRecognizer>(
() => HorizontalDragGestureRecognizer(debugOwner: this), () => HorizontalDragGestureRecognizer(debugOwner: this),
(HorizontalDragGestureRecognizer instance) { (HorizontalDragGestureRecognizer instance) {
instance instance
@@ -549,7 +562,8 @@ class GestureDetector extends StatelessWidget {
onPanUpdate != null || onPanUpdate != null ||
onPanEnd != null || onPanEnd != null ||
onPanCancel != null) { onPanCancel != null) {
gestures[PanGestureRecognizer] = GestureRecognizerFactoryWithHandlers<PanGestureRecognizer>( gestures[PanGestureRecognizer] =
GestureRecognizerFactoryWithHandlers<PanGestureRecognizer>(
() => PanGestureRecognizer(debugOwner: this), () => PanGestureRecognizer(debugOwner: this),
(PanGestureRecognizer instance) { (PanGestureRecognizer instance) {
instance instance
@@ -564,7 +578,8 @@ class GestureDetector extends StatelessWidget {
} }
if (onScaleStart != null || onScaleUpdate != null || onScaleEnd != null) { if (onScaleStart != null || onScaleUpdate != null || onScaleEnd != null) {
gestures[ScaleGestureRecognizer] = GestureRecognizerFactoryWithHandlers<ScaleGestureRecognizer>( gestures[ScaleGestureRecognizer] =
GestureRecognizerFactoryWithHandlers<ScaleGestureRecognizer>(
() => ScaleGestureRecognizer(debugOwner: this), () => ScaleGestureRecognizer(debugOwner: this),
(ScaleGestureRecognizer instance) { (ScaleGestureRecognizer instance) {
instance instance
@@ -579,7 +594,8 @@ class GestureDetector extends StatelessWidget {
onForcePressPeak != null || onForcePressPeak != null ||
onForcePressUpdate != null || onForcePressUpdate != null ||
onForcePressEnd != null) { onForcePressEnd != null) {
gestures[ForcePressGestureRecognizer] = GestureRecognizerFactoryWithHandlers<ForcePressGestureRecognizer>( gestures[ForcePressGestureRecognizer] =
GestureRecognizerFactoryWithHandlers<ForcePressGestureRecognizer>(
() => ForcePressGestureRecognizer(debugOwner: this), () => ForcePressGestureRecognizer(debugOwner: this),
(ForcePressGestureRecognizer instance) { (ForcePressGestureRecognizer instance) {
instance instance
@@ -591,13 +607,12 @@ class GestureDetector extends StatelessWidget {
); );
} }
if ( if (onMultiTapDown != null ||
onMultiTapDown != null || onMultiTapUp != null ||
onMultiTapUp != null || onMultiTap != null ||
onMultiTap != null || onMultiTapCancel != null) {
onMultiTapCancel != null gestures[MultiTapGestureRecognizer] =
) { GestureRecognizerFactoryWithHandlers<MultiTapGestureRecognizer>(
gestures[MultiTapGestureRecognizer] = GestureRecognizerFactoryWithHandlers<MultiTapGestureRecognizer>(
() => MultiTapGestureRecognizer(debugOwner: this), () => MultiTapGestureRecognizer(debugOwner: this),
(MultiTapGestureRecognizer instance) { (MultiTapGestureRecognizer instance) {
instance instance
@@ -616,9 +631,11 @@ class GestureDetector extends StatelessWidget {
child: child, child: child,
); );
} }
@override @override
void debugFillProperties(DiagnosticPropertiesBuilder properties) { void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties); super.debugFillProperties(properties);
properties.add(EnumProperty<DragStartBehavior>('startBehavior', dragStartBehavior)); properties.add(
EnumProperty<DragStartBehavior>('startBehavior', dragStartBehavior));
} }
} }

View File

@@ -7,171 +7,173 @@ import 'embedded_game_widget.dart';
import 'game.dart'; import 'game.dart';
bool _hasGestureDetectors(Game game) => bool _hasGestureDetectors(Game game) =>
game is TapDetector || game is TapDetector ||
game is SecondaryTapDetector || game is SecondaryTapDetector ||
game is DoubleTapDetector || game is DoubleTapDetector ||
game is LongPressDetector || game is LongPressDetector ||
game is VerticalDragDetector || game is VerticalDragDetector ||
game is HorizontalDragDetector || game is HorizontalDragDetector ||
game is ForcePressDetector || game is ForcePressDetector ||
game is PanDetector || game is PanDetector ||
game is ScaleDetector || game is ScaleDetector ||
game is MultiTouchTapDetector; game is MultiTouchTapDetector;
Widget _applyGesturesDetectors(Game game, Widget child) { Widget _applyGesturesDetectors(Game game, Widget child) {
return flame_detector.GestureDetector( return flame_detector.GestureDetector(
// Taps // Taps
onTap: game is TapDetector ? () => (game as TapDetector).onTap() : null, onTap: game is TapDetector ? () => (game as TapDetector).onTap() : null,
onTapCancel: game is TapDetector onTapCancel:
? () => (game as TapDetector).onTapCancel() game is TapDetector ? () => (game as TapDetector).onTapCancel() : null,
: null, onTapDown: game is TapDetector
onTapDown: game is TapDetector ? (TapDownDetails d) => (game as TapDetector).onTapDown(d)
? (TapDownDetails d) => (game as TapDetector).onTapDown(d) : null,
: null, onTapUp: game is TapDetector
onTapUp: game is TapDetector ? (TapUpDetails d) => (game as TapDetector).onTapUp(d)
? (TapUpDetails d) => (game as TapDetector).onTapUp(d) : null,
: null,
// MultiTaps // MultiTaps
onMultiTap: game is MultiTouchTapDetector ? (int pointerId) => (game as MultiTouchTapDetector).onTap(pointerId) : null, onMultiTap: game is MultiTouchTapDetector
onMultiTapCancel: game is MultiTouchTapDetector ? (int pointerId) => (game as MultiTouchTapDetector).onTap(pointerId)
? (int pointerId) => (game as MultiTouchTapDetector).onTapCancel(pointerId) : null,
: null, onMultiTapCancel: game is MultiTouchTapDetector
onMultiTapDown: game is MultiTouchTapDetector ? (int pointerId) =>
? (int pointerId, TapDownDetails d) => (game as MultiTouchTapDetector).onTapDown(pointerId, d) (game as MultiTouchTapDetector).onTapCancel(pointerId)
: null, : null,
onMultiTapUp: game is MultiTouchTapDetector onMultiTapDown: game is MultiTouchTapDetector
? (int pointerId, TapUpDetails d) => (game as MultiTouchTapDetector).onTapUp(pointerId, d) ? (int pointerId, TapDownDetails d) =>
: null, (game as MultiTouchTapDetector).onTapDown(pointerId, d)
: null,
onMultiTapUp: game is MultiTouchTapDetector
? (int pointerId, TapUpDetails d) =>
(game as MultiTouchTapDetector).onTapUp(pointerId, d)
: null,
// Secondary taps // Secondary taps
onSecondaryTapDown: game is SecondaryTapDetector onSecondaryTapDown: game is SecondaryTapDetector
? (TapDownDetails d) => ? (TapDownDetails d) =>
(game as SecondaryTapDetector).onSecondaryTapDown(d) (game as SecondaryTapDetector).onSecondaryTapDown(d)
: null, : null,
onSecondaryTapUp: game is SecondaryTapDetector onSecondaryTapUp: game is SecondaryTapDetector
? (TapUpDetails d) => ? (TapUpDetails d) => (game as SecondaryTapDetector).onSecondaryTapUp(d)
(game as SecondaryTapDetector).onSecondaryTapUp(d) : null,
: null, onSecondaryTapCancel: game is SecondaryTapDetector
onSecondaryTapCancel: game is SecondaryTapDetector ? () => (game as SecondaryTapDetector).onSecondaryTapCancel()
? () => (game as SecondaryTapDetector).onSecondaryTapCancel() : null,
: null,
// Double tap // Double tap
onDoubleTap: game is DoubleTapDetector onDoubleTap: game is DoubleTapDetector
? () => (game as DoubleTapDetector).onDoubleTap() ? () => (game as DoubleTapDetector).onDoubleTap()
: null, : null,
// Long presses // Long presses
onLongPress: game is LongPressDetector onLongPress: game is LongPressDetector
? () => (game as LongPressDetector).onLongPress() ? () => (game as LongPressDetector).onLongPress()
: null, : null,
onLongPressStart: game is LongPressDetector onLongPressStart: game is LongPressDetector
? (LongPressStartDetails d) => ? (LongPressStartDetails d) =>
(game as LongPressDetector).onLongPressStart(d) (game as LongPressDetector).onLongPressStart(d)
: null, : null,
onLongPressMoveUpdate: game is LongPressDetector onLongPressMoveUpdate: game is LongPressDetector
? (LongPressMoveUpdateDetails d) => ? (LongPressMoveUpdateDetails d) =>
(game as LongPressDetector).onLongPressMoveUpdate(d) (game as LongPressDetector).onLongPressMoveUpdate(d)
: null, : null,
onLongPressUp: game is LongPressDetector onLongPressUp: game is LongPressDetector
? () => (game as LongPressDetector).onLongPressUp() ? () => (game as LongPressDetector).onLongPressUp()
: null, : null,
onLongPressEnd: game is LongPressDetector onLongPressEnd: game is LongPressDetector
? (LongPressEndDetails d) => ? (LongPressEndDetails d) =>
(game as LongPressDetector).onLongPressEnd(d) (game as LongPressDetector).onLongPressEnd(d)
: null, : null,
// Vertical drag // Vertical drag
onVerticalDragDown: game is VerticalDragDetector onVerticalDragDown: game is VerticalDragDetector
? (DragDownDetails d) => ? (DragDownDetails d) =>
(game as VerticalDragDetector).onVerticalDragDown(d) (game as VerticalDragDetector).onVerticalDragDown(d)
: null, : null,
onVerticalDragStart: game is VerticalDragDetector onVerticalDragStart: game is VerticalDragDetector
? (DragStartDetails d) => ? (DragStartDetails d) =>
(game as VerticalDragDetector).onVerticalDragStart(d) (game as VerticalDragDetector).onVerticalDragStart(d)
: null, : null,
onVerticalDragUpdate: game is VerticalDragDetector onVerticalDragUpdate: game is VerticalDragDetector
? (DragUpdateDetails d) => ? (DragUpdateDetails d) =>
(game as VerticalDragDetector).onVerticalDragUpdate(d) (game as VerticalDragDetector).onVerticalDragUpdate(d)
: null, : null,
onVerticalDragEnd: game is VerticalDragDetector onVerticalDragEnd: game is VerticalDragDetector
? (DragEndDetails d) => ? (DragEndDetails d) =>
(game as VerticalDragDetector).onVerticalDragEnd(d) (game as VerticalDragDetector).onVerticalDragEnd(d)
: null, : null,
onVerticalDragCancel: game is VerticalDragDetector onVerticalDragCancel: game is VerticalDragDetector
? () => (game as VerticalDragDetector).onVerticalDragCancel() ? () => (game as VerticalDragDetector).onVerticalDragCancel()
: null, : null,
// Horizontal drag // Horizontal drag
onHorizontalDragDown: game is HorizontalDragDetector onHorizontalDragDown: game is HorizontalDragDetector
? (DragDownDetails d) => ? (DragDownDetails d) =>
(game as HorizontalDragDetector).onHorizontalDragDown(d) (game as HorizontalDragDetector).onHorizontalDragDown(d)
: null, : null,
onHorizontalDragStart: game is HorizontalDragDetector onHorizontalDragStart: game is HorizontalDragDetector
? (DragStartDetails d) => ? (DragStartDetails d) =>
(game as HorizontalDragDetector).onHorizontalDragStart(d) (game as HorizontalDragDetector).onHorizontalDragStart(d)
: null, : null,
onHorizontalDragUpdate: game is HorizontalDragDetector onHorizontalDragUpdate: game is HorizontalDragDetector
? (DragUpdateDetails d) => ? (DragUpdateDetails d) =>
(game as HorizontalDragDetector).onHorizontalDragUpdate(d) (game as HorizontalDragDetector).onHorizontalDragUpdate(d)
: null, : null,
onHorizontalDragEnd: game is HorizontalDragDetector onHorizontalDragEnd: game is HorizontalDragDetector
? (DragEndDetails d) => ? (DragEndDetails d) =>
(game as HorizontalDragDetector).onHorizontalDragEnd(d) (game as HorizontalDragDetector).onHorizontalDragEnd(d)
: null, : null,
onHorizontalDragCancel: game is HorizontalDragDetector onHorizontalDragCancel: game is HorizontalDragDetector
? () => (game as HorizontalDragDetector).onHorizontalDragCancel() ? () => (game as HorizontalDragDetector).onHorizontalDragCancel()
: null, : null,
// Force presses // Force presses
onForcePressStart: game is ForcePressDetector onForcePressStart: game is ForcePressDetector
? (ForcePressDetails d) => ? (ForcePressDetails d) =>
(game as ForcePressDetector).onForcePressStart(d) (game as ForcePressDetector).onForcePressStart(d)
: null, : null,
onForcePressPeak: game is ForcePressDetector onForcePressPeak: game is ForcePressDetector
? (ForcePressDetails d) => ? (ForcePressDetails d) =>
(game as ForcePressDetector).onForcePressPeak(d) (game as ForcePressDetector).onForcePressPeak(d)
: null, : null,
onForcePressUpdate: game is ForcePressDetector onForcePressUpdate: game is ForcePressDetector
? (ForcePressDetails d) => ? (ForcePressDetails d) =>
(game as ForcePressDetector).onForcePressUpdate(d) (game as ForcePressDetector).onForcePressUpdate(d)
: null, : null,
onForcePressEnd: game is ForcePressDetector onForcePressEnd: game is ForcePressDetector
? (ForcePressDetails d) => ? (ForcePressDetails d) =>
(game as ForcePressDetector).onForcePressEnd(d) (game as ForcePressDetector).onForcePressEnd(d)
: null, : null,
// Pan // Pan
onPanDown: game is PanDetector onPanDown: game is PanDetector
? (DragDownDetails d) => (game as PanDetector).onPanDown(d) ? (DragDownDetails d) => (game as PanDetector).onPanDown(d)
: null, : null,
onPanStart: game is PanDetector onPanStart: game is PanDetector
? (DragStartDetails d) => (game as PanDetector).onPanStart(d) ? (DragStartDetails d) => (game as PanDetector).onPanStart(d)
: null, : null,
onPanUpdate: game is PanDetector onPanUpdate: game is PanDetector
? (DragUpdateDetails d) => (game as PanDetector).onPanUpdate(d) ? (DragUpdateDetails d) => (game as PanDetector).onPanUpdate(d)
: null, : null,
onPanEnd: game is PanDetector onPanEnd: game is PanDetector
? (DragEndDetails d) => (game as PanDetector).onPanEnd(d) ? (DragEndDetails d) => (game as PanDetector).onPanEnd(d)
: null, : null,
onPanCancel: game is PanDetector onPanCancel:
? () => (game as PanDetector).onPanCancel() game is PanDetector ? () => (game as PanDetector).onPanCancel() : null,
: null,
// Scales // Scales
onScaleStart: game is ScaleDetector onScaleStart: game is ScaleDetector
? (ScaleStartDetails d) => (game as ScaleDetector).onScaleStart(d) ? (ScaleStartDetails d) => (game as ScaleDetector).onScaleStart(d)
: null, : null,
onScaleUpdate: game is ScaleDetector onScaleUpdate: game is ScaleDetector
? (ScaleUpdateDetails d) => (game as ScaleDetector).onScaleUpdate(d) ? (ScaleUpdateDetails d) => (game as ScaleDetector).onScaleUpdate(d)
: null, : null,
onScaleEnd: game is ScaleDetector onScaleEnd: game is ScaleDetector
? (ScaleEndDetails d) => (game as ScaleDetector).onScaleEnd(d) ? (ScaleEndDetails d) => (game as ScaleDetector).onScaleEnd(d)
: null, : null,
child: child, child: child,
); );
} }
class WidgetBuilder { class WidgetBuilder {
@@ -179,11 +181,11 @@ class WidgetBuilder {
Widget build(Game game) { Widget build(Game game) {
Widget widget = Container( Widget widget = Container(
color: game.backgroundColor(), color: game.backgroundColor(),
child: Directionality( child: Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: EmbeddedGameWidget(game), child: EmbeddedGameWidget(game),
), ),
); );
if (_hasGestureDetectors(game)) { if (_hasGestureDetectors(game)) {