StringConversionExtensions extension

String common type conversions extensions

on

Properties

toBool bool

Available on String, provided by the StringConversionExtensions extension

Attempts to convert the string to a boolean value. Supports "true" and "false", case-insensitive.
no setter
toDate DateTime

Available on String, provided by the StringConversionExtensions extension

Attempts to parse the string into a DateTime object. Returns null if the parsing fails.
no setter
toDateTime DateTime

Available on String, provided by the StringConversionExtensions extension

Returns the DateTime represented by this string. Defaults to Unix Epoch (1970-01-01) if parsing fails.
no setter
toDecimal → Decimal

Available on String, provided by the StringConversionExtensions extension

Converts the string to a Decimal. Returns null if the conversion fails. Requires the decimal package.
no setter
toDouble double

Available on String, provided by the StringConversionExtensions extension

Converts the string to a double. Returns null if the conversion fails.
no setter
toDoubleList List<double>

Available on String, provided by the StringConversionExtensions extension

Converts a comma-separated string into a List<double>. Fails silently for non-numeric parts.
no setter
toInt int

Available on String, provided by the StringConversionExtensions extension

Converts the string to an integer. Returns null if the conversion fails.
no setter
toIntList List<int>

Available on String, provided by the StringConversionExtensions extension

Converts a comma-separated string into a List<int>. Fails silently for non-numeric parts.
no setter
toJson → dynamic

Available on String, provided by the StringConversionExtensions extension

Attempts to decode the string as a JSON object. Returns null if decoding fails.
no setter
toList List

Available on String, provided by the StringConversionExtensions extension

Attempts to decode the string as a List<dynamic> from JSON. Returns an empty list if decoding fails.
no setter
toNum num

Available on String, provided by the StringConversionExtensions extension

Converts the string to a num (which can be either int or double). Returns null if the conversion fails.
no setter
toUri Uri?

Available on String, provided by the StringConversionExtensions extension

Converts the string to a Uri object. Returns null if the conversion fails or the URL is invalid.
no setter
utc1970 DateTime

Available on String, provided by the StringConversionExtensions extension

Converts the string to a Uri object. Returns null if the conversion fails or the URL is invalid.
no setter

Methods

formatMoney({String symbol = '', int decimalDigits = 2}) String

Available on String, provided by the StringConversionExtensions extension

Attempts to parse the string as a number and formats it as a money string with custom prefix.
toMoney({int decimalDigits = 2}) String

Available on String, provided by the StringConversionExtensions extension

Attempts to parse the string as a number and formats it as a money string.