Untitled

mail@pastecode.io avatar
unknown
dart
2 years ago
714 B
1
Indexable
Never
body: GestureDetector(
  child: GameBoard(isPlaying: isPlaying, body: body, food: food),
  onHorizontalDragUpdate: (details) {
    if (direction != 'left' && details.delta.dx > 0) {
      print("right ${details.delta.dx}");
      direction = directionRIGHT;
    } else if (direction != 'right' && details.delta.dx < 0) {
      print("left ${details.delta.dx}");
      direction = directionLEFT;
    }
  },
  onVerticalDragUpdate: (details) {
    if (direction != 'down' && details.delta.dy < 0) {
      print("up ${details.delta.dy}");
      direction = directionUP;
    } else if (direction != 'up' && details.delta.dy > 0) {
      print("down ${details.delta.dy}");
      direction = directionDOWN;
    }
  },
),