TypeConverter class
Converts arbitrary values into objects specific by TypeCodes. For each TypeCode this class calls corresponding converter which applies extended conversion rules to convert the values.
See TypeCode
Example
var value1 = TypeConverter.toType(TypeCode.Integer, '123.456'); // Result: 123
var value2 = TypeConverter.toType(TypeCode.DateTime, 123); // Result: DateTime(123)
var value3 = TypeConverter.toType(TypeCode.Boolean, 'F'); // Result: false
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
asString(
TypeCode type) → String - Converts a TypeCode into its string name.
-
toNullableType<
T> (TypeCode? type, dynamic value) → T? - Converts value into an object type specified by Type Code or returns null when conversion is not possible.
-
toType<
T> (TypeCode? type, dynamic value) → T - Converts value into an object type specified by Type Code or returns type default when conversion is not possible.
-
toTypeCode(
dynamic value) → TypeCode - Gets TypeCode for specific value.
-
toTypeWithDefault<
T> (TypeCode type, dynamic value, T defaultValue) → T - Converts value into an object type specified by Type Code or returns default value when conversion is not possible.