rowByKey method

Future<List<String>?> rowByKey(
  1. Object key, {
  2. int fromColumn = 2,
  3. int length = -1,
})

Fetches row by its name.

Expands current sheet's size if requested range is out of sheet's bounds.

key - name of a requested row The column A considered to be row names

fromColumn - optional (defaults to 2), 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

Returns row as Future List of String. Returns Future null if there key is not found.

Throws GSheetsException.

Implementation

Future<List<String>?> rowByKey(
  Object key, {
  int fromColumn = 2,
  int length = -1,
}) async {
  final rKey = parseKey(key);
  checkIndex('fromColumn', fromColumn);
  final rows = await allRows();
  final rowIndex = whereFirst(rows, rKey);
  if (rowIndex < 0) return null;
  return extractSublist(
    rows[rowIndex],
    from: fromColumn - 1,
    length: length,
  );
}