insertValueByKeys method

Future<bool> insertValueByKeys(
  1. Object value, {
  2. required Object columnKey,
  3. required Object rowKey,
  4. bool eager = true,
})

Updates cell's value to value by names of its column and row.

columnKey - name of a column to insert value to The first row considered to be column names

rowKey - name of a row to insert value to The column A considered to be row names

eager - optional (defaults to true), whether to add rowKey/columnKey if absent

Returns Future true in case of success.

Throws GSheetsException.

Implementation

Future<bool> insertValueByKeys(
  Object value, {
  required Object columnKey,
  required Object rowKey,
  bool eager = true,
}) async {
  final rKey = parseKey(rowKey, 'row');
  final cKey = parseKey(columnKey, 'column');
  final rows = await allRows();
  final row = _rowOf(rows, rKey, eager);
  final column = _columnOf(rows, cKey, eager);
  if (await row < 1) return false;
  if (await column < 1) return false;
  return _ws._update(
    values: [value],
    range: await _ws._columnRange(await column, await row, 1),
    majorDimension: dimenColumns,
  );
}