Style

The group of style related methods allows you to 'style' a string and test the style of a string.

isLowerCase

 static bool isLowerCase(String? string) 

The 'isLowerCase' method returns true if the 'string' contains no upper case characters. All other characters, digits etc are allowed.

Strings.isLowerCase('abc 1234');
-> true
Strings.isLowerCase('abC 1234');
-> false

If null is passed the 'string' is treated as an empty string and 'true' is returned.

extension

The 'isLowerCase' method is available as an extension to the String class

'ABCD'.isLowerCase();
-> false

isPrintable

static bool isPrintable(int? character) 

The isPrintable method returns true of 'character' is a printable character.

Whitespace characters are considered as non-printable.

Strings.isPrintable('\n');
-> false

isUpperCase

 static bool isUpperCase(String? string) 

The 'isUpperCase' method returns true if the 'string' contains no lower case characters. All other characters, digits etc are allowed.

Strings.isUpperCase('ABC 1234');
-> true
Strings.isUpperCase('ABc 1234');
-> false

If null is passed the 'string' is treated as an empty string and 'true' is returned.

extension

The 'isUpperCase' method is available as an extension on the String class.

'abcd'.isUpperCase();
-> false

startsWithLowerCase

 static bool startsWithLowerCase(String? string) 

The 'startsWithLowerCase' method returns true if the 'string' starts with an lower case character.

Strings.startsWithLowerCase('abc 1234');
-> true
Strings.startsWithLowerCase('Abc 1234');
-> false

If null is passed the 'string' is treated as an empty string and 'false' is returned.

extension

The method 'startsWithLowerCase' is available as an extension on the String class.

'abcDEF'.startsWithLowerCase();
-> true

startsWithUpperCase

 static bool startsWithUpperCase(String? string) 

The 'startsWithUpperCase' method returns true if the 'string' starts with a lower case character.

Strings.startsWithUpperCase('ABC 1234');
-> true
Strings.startsWithUpperCase('abc 1234');
-> false

If null is passed the 'string' is treated as an empty string and 'false' is returned.

extension

The method 'startsWithUpperCase' is available as an extension method on the String class.

'ABC'.startsWithUpperCase();
-> true

toCamelCase

 static String toCamelCase(String? string, {bool lower = fase});

The 'toCamelCase' method converts the string to camel case.

Strings.toCamelCase('abc_one');
-> 'AbcOne'

If 'lower' is set to true then the first chacter of the resulting string is lowercase.

Strings.toCamelCase('abc_one', lower=true);
-> 'abcOne'

If null is passed the 'string' is treated as an empty string and an empty string is returned.

extension

The 'toCamelCase' method is available as an extension on the String class.

'abc_one'.toCamelCase();
-> 'AbcOne'

toCapitalised

static String toCapitalised(String? string);

The 'toCapitalised' capitalises the first character of the 'string'.

Strings.toCapitalised('abc one');
-> 'Abc one'

If null is passed the 'string' is treated as an empty string and an empty string is returned.

extension

The 'toCapitialised' method is available as an extension on the String class.

'john'.toCapitalised();
-> 'John'

toLowerCase

 static String toLowerCase(String? string);

The 'toLowerCase' method converts the string all lower case.

Strings.toLowerCase('Abc One');
-> 'abc one'

If null is passed the 'string' is treated as an empty string and an empty string is returned.

toProperCase

 static String toProperCase(String? string);

The 'toProperCase' method converts the string to proper case where in the first letter of each word is capitalised.

Strings.toProperCase('abc one');
-> 'Abc One'

If null is passed the 'string' is treated as an empty string and an empty string is returned.

toSnakeCase

 static String toSnakeCase(String? string);

The 'toSnakeCase' method converts the string to snake case where each word is separated by an underscore and all characters are lower case.

Strings.toSnakeCase('abc one');
-> 'abc_one'
Strings.toSnakeCase('AbcOne');
-> 'abc_one'

If null is passed the 'string' is treated as an empty string and an empty string is returned.

extension

The 'toSnakeCase' method is available as an extension method on the String class.

'AbcDef'.toSnakeCase();
-> 'abc_def'

Last updated