autoConverter function
Returns a converter from String to the specified primitive type.
Supported types: bool
, int
, double
, and Uri
.
Note: Use the convert annotation for all other types.
Implementation
Converter autoConverter(Type T) => (T == bool)
? Convert.toBool
: (T == int)
? Convert.toInt
: (T == double)
? Convert.toDouble
: (T == Uri)
? Convert.toUri
: (T == dynamic || T == String)
? (s) => s // dynamic == default String
: throw UnsupportedError('No converter for $T');