getIndexFromPosition method
Implementation
Index getIndexFromPosition(Offset pos) {
late int i;
late int j;
if (pos.dx <= columnPos[0]) {
j = 0;
} else if (pos.dx >= columnPos.last) {
j = columnPos.length - 1;
} else {
j = binarySearch(columnPos, pos.dx, 0, columnPos.length - 1);
}
if (pos.dy <= rowPos[0]) {
i = 0;
} else if (pos.dy >= rowPos.last) {
i = rowPos.length - 1;
} else {
i = binarySearch(rowPos, pos.dy, 0, rowPos.length - 1);
}
return Index(i, j);
}