StringConverter class

Converts arbitrary values into strings using extended conversion rules:

  • Numbers: are converted with '.' as decimal point
  • DateTime: using ISO format
  • Boolean: "true" for true and "false" for false
  • Arrays: as comma-separated list
  • Other objects: using toString() method

Example

var value1 = StringConverter.ToString(123.456); // Result: "123.456"
var value2 = StringConverter.ToString(true); // Result: "true"
var value3 = StringConverter.ToString(new Date(2018,0,1)); // Result: "2018-01-01T00:00:00.00"
var value4 = StringConverter.ToString([1,2,3]); // Result: "1,2,3"

Constructors

StringConverter()

Properties

hashCode → int
The hash code for this object. [...]
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator. [...]
inherited

Static Methods

toNullableString(dynamic value) → String
Converts value into string or returns null when value is null. [...]
toString2(dynamic value) → String
Converts value into string or returns "" when value is null. [...]
toStringWithDefault(dynamic value, String defaultValue) → dynamic
Converts value into string or returns default when value is null. [...]