column method

Future<Map<String, String>> column(
  1. int column, {
  2. int fromRow = 1,
  3. int length = -1,
  4. int mapTo = 1,
})

Fetches specified column, maps it to other column and returns map.

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

column - index of a requested column (values of returned map), columns start at index 1 (column A)

fromRow - optional (defaults to 1), index of a row that requested column starts from (values before fromRow will be skipped), rows start at index 1

length - optional (defaults to -1), the length of a requested column if length is -1, all values starting from fromRow will be returned

mapTo - optional (defaults to 1), index of a column to map values to (keys of returned map), columns start at index 1 (column A)

Returns column as Future Map of String to String.

Throws GSheetsException.

Implementation

Future<Map<String, String>> column(
  int column, {
  int fromRow = 1,
  int length = -1,
  int mapTo = 1,
}) async {
  checkIndex('column', column);
  checkIndex('mapTo', mapTo);
  checkMapTo(column, mapTo);
  final columns = await _values.allColumns(
    fromRow: fromRow,
    length: length,
  );
  final keys = get(columns, at: mapTo - 1, or: <String>[])!;
  final values = get(columns, at: column - 1, or: <String>[])!;
  return _wrap(keys, values);
}