FloatConverter class
Converts arbitrary values into float using extended conversion rules:
- Strings are converted to float values
- DateTime: total number of milliseconds since unix epoсh
- Boolean: 1 for true and 0 for false
Example
var value1 = FloatConverter.toNullableFloat('ABC'); // Result: null
var value2 = FloatConverter.toNullableFloat('123.456'); // Result: 123.456
var value3 = FloatConverter.toNullableFloat(true); // Result: 1
var value4 = FloatConverter.toNullableFloat( Date()); // Result: current milliseconds
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
-
toFloat(
dynamic value) → double - Converts value into float or returns 0 when conversion is not possible.
-
toFloatWithDefault(
dynamic value, double defaultValue) → double - Converts value into float or returns default when conversion is not possible.
-
toNullableFloat(
dynamic value) → double? - Converts value into float or returns null when conversion is not possible.