Strings class

Copyright (C) OnePub IP Pty Ltd - All Rights Reserved Unauthorized copying of this file, via any medium is strictly prohibited Proprietary and confidential Written by Brett Sutton bsutton@onepub.dev, Jan 2022

A set of String utility functions

A blank string is a string which contains only whitespace An empty string is a string of zero length

Constructors

Strings()

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

abbreviate(String str, int maxWidth, {int offset = 0}) String
Abbreviate a string to maxWidth by truncating the string and adding '...' to then truncated string.
equals(String? lhs, String? rhs) bool
Safely compares two strings. If both are null returns true If one of them is null returns false if both are the same returns true.
isBlank(String? value) bool
true if the value is null or Blank. Whitespace is ignored See: isEmpty to check for a zero length string.
isEmpty(String? value) bool
true if the value is null, or is a zero length String
isNotBlank(String? value) bool
true if the value is not null and not Blank. A string containing only whitespace is considered blank. See: isNotEmpty to check for non-zero length string.
isNotEmpty(String? value) bool
true if the value is not null and is not a zero length String
isNumeric(String? string) bool
Checks if string is a number by attempting to parse it as a double. INFINITY and NaN are not treated as numbers.
left(String value, int fromLeft) String
Returns the first fromLeft characters from value If fromLeft is longer than value then an RangeError is thrown.
nullToEmpty(String? value) String
If value is null we return an zero length string otherwise we return value.
orElse(String? value, String elseValue) String
If value is null the elseValue is returned otherwise value is returned.
properCase(String sentence) String
Converts sentence to proper case by capitalising the first letter of each word and forcing all other characters to lower case.
Returns all characters from value starting at fromRight inclusive. If fromRight is outside the bounds of value then an RangeError is thrown.