flutter: 重构 GestureDetector()
This commit is contained in:
parent
c7802c997c
commit
91e6d460a5
|
@ -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);
|
||||
},
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue