valueAt<T> method
Read an appropriate value from SQLite Value or Column based on SQLite type affinity by index
.
When the method is used to read value from select query, the returned value is also determine based on type declaration such as DateTime, bool ...etc.
Implementation
@override
T? valueAt<T>(int index) {
final type = Driver.binder.column_type(_stmt, index);
switch (type) {
case sqlite.NULL:
return null;
case sqlite.INTEGER:
return intValueAt(index)?.toAppropriateTypeValue(_declareType[index], T);
case sqlite.FLOAT:
if (T == double || T == num || T == dynamic) return doubleValueAt(index) as T?;
break;
case sqlite.TEXT:
return stringValueAt(index)?.toAppropriateTypeValue(_declareType[index], T);
case sqlite.BLOB:
if (T == Uint8List || T == dynamic) return blobValueAt(index) as T?;
break;
}
throw sql.DatabaseException('unsupported sqlite value of data type $type at index $index.');
}