MiscExtensions extension Null safety

on

Properties

capitalize String?
Capitalizes the String in normal form.
read-only
charOccurences List<Map<String, int>>
Finds all character occurences and returns count as:
read-only
countWords int
Returns the word count in the given String.
read-only
digitCount int
Returns the digit count of the String.
read-only
formatFileSize String?
Formats the String to show its proper file size.
read-only
hasSameCharacters bool
Checks if the String is consisted of same characters (ignores cases).
read-only
isAscii bool
Checks whether the String is a valid ASCII string.
read-only
isBlank bool
Checks if the String is Blank (null, empty or only white spaces).
read-only
isCreditCard bool?
Checks if the String provided is a valid credit card number using Luhn Algorithm.
read-only
isDate bool
Checks whether the String is a valid Date:
read-only
isGreek bool?
Checks if the String has only Greek characters.
read-only
isGreekId bool
Checks whether the provided String is a valid Greek ID number.
read-only
isGuid bool
Checks whether the String is a valid Guid.
read-only
isIban bool
Checks whether the String is a valid IBAN.
read-only
isIpv4 bool
Checks whether the String is a valid IPv4.
read-only
isIpv6 bool
Checks whether the String is a valid IPv6.
read-only
isLatin bool
Checks if the String has only Latin characters.
read-only
isLowerCase bool?
Checks whether the String is in lowercase.
read-only
isMail bool
Checks whether the String is a valid mail.
read-only
isNotBlank bool
Checks if the String is not blank (null, empty or only white spaces).
read-only
isNotNull bool
Checks whether the String is not null.
read-only
isNull bool
Checks whether the String is null.
read-only
isNumber bool
Checks whether the String is a number.
read-only
isPalindrome bool
Checks whether the String is a palindrome.
read-only
isStrongPassword bool
Checks whether the String complies to below rules :
read-only
isSwiftCode bool?
Checks whether the provided String is a valid Swift code.
read-only
isUpperCase bool?
Checks whether the String is in uppercase.
read-only
isUrl bool
Checks whether the String is a valid URL.
read-only
md5 String?
Returns the MD5 hash of the String.
read-only
onlyGreek String?
Returns only the Greek characters from the String.
read-only
onlyLatin String?
Returns only the Latin characters from the String.
read-only
onlyLetters String?
Returns only the Latin OR Greek characters from the String.
read-only
onlyNumbers String?
Returns only the numbers from the String.
read-only
quote String?
Quotes the String adding "" at the start & at the end.
read-only
removeLetters String?
Removes only the letters from the String.
read-only
removeNumbers String?
Removes only the numbers from the String.
read-only
removeSpecial String?
Returns all special characters from the String.
read-only
removeWhiteSpace String?
Removes all whitespace from the String.
read-only
replaceGreek String?
Replaces all greek characters with latin. Comes handy when you want to normalize text for search.
read-only
reverse String?
Returns the String reversed.
read-only
shuffle String?
Shuffles the given String's characters.
read-only
stripHtml String?
Strips all HTML code from String.
read-only
toArray List<String>
Returns a list of the String's characters.
read-only
toBool bool?
Checks the String and maps the value to a bool if possible.
read-only
toCamelCase String?
Returns the String in camelcase.
read-only
toLeet String?
Transforms the String to 1337 alphabet.
read-only
toSlug String?
Returns the String to slug case.
read-only
toSnakeCase String?
Returns the String to snake_case.
read-only
toTitleCase String?
Returns the String title cased.
read-only
trimAll String?
Trims leading and trailing spaces from the String, so as extra spaces in between words.
read-only

Methods

addAfter(String pattern, String adition) String?
Adds a String after the first match of the pattern. The pattern should not be null.
addBefore(String pattern, String adition) String?
Adds a String before the first match of the pattern. The pattern should not be null.
after(String pattern) String?
Returns the String after a specific character.
append(String suffix) String
Appends a suffix to the String.
asIf(bool comparison(String?), String? trueString, String? falseString) String?
Compares this using comparison and returns trueString if true, otherwise return falseString.
before(String pattern) String?
Returns the String before a specific character
charAt(int index) String?
Returns the character at index of the String.
charCount(String char) int
Finds a specific's character occurence in the String.
containsAll(List<String?> patterns) bool
Checks if the String matches ALL given patterns.
containsAny(List<String?> patterns) bool
Checks if the String matches ANY of the given patterns.
defaultValue(String defautlValue) String?
Provide default value if the String is null.
findPattern({required String pattern}) List<int>
Given a pattern returns the starting indices of all occurences of the pattern in the String.
first({int n = 1}) String?
Returns the first n characters of the String.
firstDayOfMonth({String locale = 'en'}) String?
Returns the first day of the month from the provided DateTime in String format.
formatWithMask(String mask, {String specialChar = '#'}) String?
Inspired from Vincent van Proosdij.
getDayFromDate({String locale = 'en'}) String?
Returns the day name of the date provided in String format.
getJaro(String t) double
The Jaro distance is a measure of edit distance between two strings
getLevenshtein(String b) int?
The Levenshtein distance between two words is the minimum number of single-character
getMonthFromDate({String locale = 'en'}) String?
Returns the month name of the date provided in String format.
getOppositeChar() String?
Returns the opposite wrap char of the String if possible, otherwise returns the same String.
ifBlank(String? newString) String?
Return this if not blank. Otherwise return newString.
ifEmpty(Function act) String?
If the provided String is empty do something.
ifNull(Function act) String
If the provided String is null do something.
isAnagramOf(String s) bool
Checks whether the String is an anagram of the provided String.
isCloseWrapChar() bool
Check if the String is a close wrap char: >, }, ], ", '.
isIn(Iterable<String?> strings) bool
Checks if the String exists in a given Iterable<String>
isMixedCase() bool
Checks whether the String is consisted of both upper and lower case letters.
isOpenWrapChar() bool
Check if String is a open wrap char: <, {, [, ", '.
last({int n = 1}) String?
Returns the last n characters of the String.
lastDayOfMonth({String locale = 'en'}) String?
Returns the last day of the month from the provided DateTime in String format.
leftOf(String char) String?
Returns the left side of the String starting from char.
maxChars(int n) String?
Trims the String to have maximum n characters.
mostFrequent({bool ignoreSpaces = false}) String?
Finds the most frequent character in the String.
prepend(String prefix) String
Prepends a prefix to the String.
readTime({int wordsPerMinute = 200}) int
Returns the average read time duration of the given String in seconds.
removeAfter(String pattern) String?
Removes everything in the String after the first match of the pattern.
removeBefore(String pattern) String?
Removes everything in the String before the match of the pattern.
removeFirst(int n) String?
Removes the first n characters from the String.
removeFirstAndLastAny(List<String?> patterns) String?
Continuously removes from the beginning & the end of the String, any match in patterns.
removeFirstAndLastEqual(String? pattern) String?
Removes any pattern match from the beginning & the end of the String.
removeFirstAny(List<String?> patterns) String?
Continuously removes from the beginning of the String any match in patterns.
removeFirstEqual(String? pattern) String?
Removes any pattern match from the beginning of the String.
removeLast(int n) String?
Removes the last n characters from the String.
removeLastAny(List<String?> patterns) String?
Continuously removes from the end of the String, any match in patterns.
removeLastEqual(String? pattern) String?
Removes the pattern from the end of the String.
repeat(int count) String?
Repeats the String count times.
replaceAtIndex({required int index, required String replacement}) String?
Adds a replacement character at index of the String.
reverseSlash(int direction) String?
Reverses slash in the String, by providing direction,
rightOf(String char) String?
Returns the right side of the String starting from char.
squeeze(String char) String?
Squeezes the String by removing repeats of a given character.
swapCase() String?
Swaps the case in the String.
toDouble() double?
Converts a String todouble if possible.
toGreekUpperCase() String?
Properly upper cases Greek letters removing their tones.
toInt() int?
Converts a String toint if possible.
toNum() num?
Converts a String to a numeric value if possible.
toPriceAmount({String? currencySymbol}) String?
Tries to format the current String to price amount.
truncate(int length) String?
Truncates the String when more than length characters exist.
truncateMiddle(int maxChars) String?
Truncates a long String in the middle while retaining the beginning and the end.
wrap(String? before, {String? after}) String
Wraps the String between two strings. If before is a wrap char and after is ommited, the method resolve after using getOppositeChar.

Operators

operator -(String? s) String
Removes a text from the String.
operator <(String s) bool
Checks if the length! of the String is less than the length of s.
operator <=(String s) bool
Checks if the length! of the String is less or equal than the length of s.
operator >(String s) bool
Checks if the length! of the String is more than the length of s.
operator >=(String s) bool
Checks if the length! of the String is more or equal than the length of s.