flutter: 重构 GestureDetector()

This commit is contained in:
Calcitem 2020-11-15 09:23:48 +08:00
parent c7802c997c
commit 91e6d460a5
1 changed files with 13 additions and 6 deletions

View File

@ -76,18 +76,25 @@ class BoardWidget extends StatelessWidget {
final gridWidth = (width - padding * 2);
final squareWidth = gridWidth / 7;
final dx = d.localPosition.dx, dy = d.localPosition.dy;
final row = (dy - padding - digitsHeight) ~/ squareWidth;
final dx = d.localPosition.dx;
final dy = d.localPosition.dy;
final column = (dx - padding) ~/ squareWidth;
if (column < 0 || column > 6) {
print("Tap on column $column skip");
return;
}
final row = (dy - padding - digitsHeight) ~/ squareWidth;
if (row < 0 || row > 6) {
print("Tap on row $row skip");
return;
}
final index = row * 7 + column;
print("Tap on ($row, $column) <$index>");
if (row < 0 || row > 6) return;
if (column < 0 || column > 6) return;
onBoardTap(context, index);
},
);