lastRow method
Fetches last row.
Expands current sheet's size if requested range is out of sheet's bounds.
fromColumn
- optional (defaults to 1), index of a column that requested row
starts from (values before fromColumn
will be skipped),
columns start at index 1 (column A)
length
- optional (defaults to -1), the length of a requested row
if length is -1
, all values starting from fromColumn
will be returned
inRange
- optional (defaults to false), whether should be fetched last
row in range (respects fromColumn
and length
) or last row in table
Returns last row as Future List
of String.
Returns Future null
if there are no rows.
Throws GSheetsException.
Implementation
Future<List<String>?> lastRow({
int fromColumn = 1,
int length = -1,
bool inRange = false,
}) async {
if (inRange) {
final rows = await allRows(
fromColumn: fromColumn,
length: length,
);
if (rows.isEmpty) return null;
return rows.last;
} else {
checkIndex('fromColumn', fromColumn);
final rows = await allRows();
if (rows.isEmpty) return null;
return extractSublist(
rows.last,
from: fromColumn - 1,
length: length,
);
}
}