readAs<T extends Object> method
- BaseSqlType<
T> type, - SqlTypes types
Interprets the rawSqlValue as a drift type
under the configuration
given by types
.
A given rawSqlValue may have different Dart representations that would
be given to you by drift. For instance, the SQL value 1
could have the
following possible Dart interpretations:
- The bool constant
true
. - The int constant
1
- The big integer BigInt.one.
- All DateTime values having
1
as their UNIX timestamp in seconds (this depends on the configuration - drift can be configured to store date times as text too).
For this reason, it is not always possible to directly map these raw
values to Dart without further information. Drift also needs to know the
expected type and some configuration options for context. For all SQL
types except ANY
, drift will do this for you behind the scenes.
You can obtain a types
instance from a database or DAO by using
DatabaseConnectionUser.typeMapping.
Implementation
T readAs<T extends Object>(BaseSqlType<T> type, SqlTypes types) {
return types.read<T>(type, rawSqlValue)!;
}