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