StringUtil class abstract

Constructors

StringUtil()

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

bifurcateFullName(String? fullName) List<String?>
Bifurcate full name into given name & surname.
camelCaseToSnakeCase(String input) String
Convert camel case to snake case.
capitalise(String str) String
Capitalises a string, i.e. converts the first letter to uppercase and all other letters to lowercase, e.g.:
computeFullName([String? givenName, String? surName]) String
Computes best-effort full name based on available name arguments
escapeChar(int c) String
Takes a character and returns the escaped string for that character. For example escapeChar(String.fromCharCode(15)) -> "\x0E". @param {character} c The character to escape. @return {string} An escaped string representing {@code c}.
escapeForHtmlEmbed(String s) String
escapeString(String str) String
Takes a string and returns the escaped string for that character. @param {string} str The string to escape. @return {string} An escaped string representing {@code str}.
formatBoolean(bool value) String
formatPercent(double? value, [int significantFigures = 2]) String
formatPercentFromFraction(num numerator, num denominator, [int significantFigures = 2]) String
formatUsPhoneNumber(String? phoneNumber) String
Formats a U.S. phone number
getBaseName(String path) String
Compute base name from path
htmlEscape(String str) String
Escapes double quote '"' and single quote ''' characters in addition to '&', '<', and '>' so that a string can be included in an HTML tag attribute value within double or single quotes.
htmlEscapePreservingNewlinesAndSpaces(String textOrHtml) String
Returns HTML-escaped text as a SafeHtml object, with newlines changed to <br> and escaping whitespace to preserve spatial formatting. Character entity #160 is used to make it safer for XML. @param {!goog.html.SafeHtml.TextOrHtml_} textOrHtml The text to escape. If the parameter is of type SafeHtml it is returned directly (no escaping is done). @return {!goog.html.SafeHtml} The escaped text, wrapped as a SafeHtml.
interpolate(String input, ConsumerSupplierFunction<String, String?> callback) String
Interpolate {} tokens in the input string
interpolateAsync(String input, ConsumerSupplierFunction<String, Future<String?>> callback) Future<String>
Interpolate {} tokens in the input string, but asynchronously
isCapitalised(String value) bool
Checks whether is capitalised
isLowerCase(int char) bool
isNumberCharacter(int codeUnit) bool
Whether is a number character
isUpperCase(int char) bool
joinList(List<String> items, String conjunction) String
Join items list
newLineToBr(String str) String
Converts \n to
s or
s. @param {string} str The string in which to convert newlines. @return {string} A copy of {@code str} with converted newlines.
ordinalSuffix(int day) String
Computes ordinal suffix based on number
padNumber(num value, int len) String
sanitiseSingleLineData(String input) String
Strip line break characters
stripNonNumericCharacters(String text) String
Strip all non-numeric characters
stripTags(String str) String
titleToSnakeCase(String input) String
Convert title (a string of words separated by spaces) to snake case.
truncate(String str, int chars) String
Truncates a string to a certain length and adds '...' if necessary. The length also accounts for the ellipsis, so a maximum length of 10 and a string 'Hello World!' produces 'Hello W...'. @param {string} str The string to truncate. @param {number} chars Max number of characters. @return {string} The truncated {@code str} string.
truncateWithCustomEllipsis(String str, int chars, String ellipsisStr) String
whitespaceEscape(String str) String
Do escaping of whitespace to preserve spatial formatting. We use character entity #160 to make it safer for xml. @param {string} str The string in which to escape whitespace. @param {bool=} opt_xml Whether to use XML compatible tags. @return {string} An escaped copy of {@code str}.