readColumnByIndex method

dynamic readColumnByIndex(
  1. int columnIndex, {
  2. Convert convert = Convert.DynamicType,
})

Reads column columnName.

By default it returns a dynamically typed value. If convert is set to Convert.StaticType the value is converted to the static type computed for the column by the query compiler.

Implementation

dynamic readColumnByIndex(int columnIndex,
    {Convert convert = Convert.DynamicType}) {
  _checkIsCurrentRow();

  Type dynamicType;
  if (convert == Convert.DynamicType) {
    dynamicType =
        _typeFromCode(bindings.sqlite3_column_type(_statement, columnIndex));
  } else {
    dynamicType = _typeFromText(bindings
        .sqlite3_column_decltype(_statement, columnIndex)
        .toDartString());
  }

  switch (dynamicType) {
    case Type.Integer:
      return readColumnByIndexAsInt(columnIndex);
    case Type.Text:
      return readColumnByIndexAsText(columnIndex);
    case Type.Null:
      return null;
    default:
  }
}