read<T> method Null safety

T read<T>(
  1. String key
)

Reads an arbitrary value from the row and maps it to a fitting dart type.

The dart type T must be supported by the type system of the database used (mostly contains booleans, strings, numbers and dates).

At the moment, this method can handle nullable and non-nullable types. In a future (major) drift version, this method may be changed to only support non-nullable types.

Implementation

T read<T>(String key) {
  final type = DriftSqlType.forNullableType<T>();
  return _db.typeMapping.read(type, data[key]) as T;
}