- Improves
after
&before
methods to include whitespace in patterns - Adds topics at the library
- Adds a new optional parameter,
defaultToBlank
, to theafter
andbefore
methods. ThedefaultToBlank
parameter allows the user to specify whether to return an empty string or the original string when no pattern is found. By default, it is set totrue
, meaning an empty string is returned. This enhancement improves the flexibility and usability of the methods.
- Changes
intl
version constraints from0.19.0
to>=0.18.1
- Library now also extends
String
so there is no need of using the bang operator onString
s that are notnull
- Bumps dependencies
- Removes Flutter from dependencies
- Improves documentation
nullIf(String? comparisonString)
: Returnsnull
ifString
equalscomparisonString
. Otherwise return theString
as is.emptyIf(String? comparisonString)
: Returns emptyString
if it equalts tocomparisonString
. Otherwise return theString
as is.replaceFirst(String pattern, String replacement)
: Returns a new string with the first occurrence of the given pattern replaced with the replacement string.replaceLast(String pattern, String replacement)
: Returns a new string with the last occurrence of the given pattern replaced with the replacement string.
insertAt
: Inserts aString
at a specified indexsplitLines
: Splits theString
into aList
of lines ('\r\n' or '\n')isJson
: Returns true if theString
is a valid JSON string
- Bumps SDK constraint from 3.0.0 to 4.0.0
- Adds screenshots in project
hasWhitespace
: Checks whether theString
has any whitespaceisLettersOnly
: Checks whether theString
is consisted of only letters (Latin & Greek atm)
greekTimeLiteralToEnglish
: Transforms the Greek μ.μ. time literal to the equivalent English PMcontainsAnyGreekCharacters
: Checks whether aString
contains any Greek characterisUnique
: Checks whether theString
is consisted of unique characterscommonCharacters
: Returns a Set of common characters between twoStrings
uncommonCharacters
: Returns a Set of uncommon characters between twoStrings
containsAllCharacters
: Checks whether theString
contains all characters
- Improves
mostFrequent()
method's performance. Also addsignoreSpaces
flag to ignore whitespace from character count - Fixes
removeWhitespace
method to properly remove all spaces - Fixes
toGreekUppercase
method missing letter "omicron - Ό" from mapping
isSwiftCode
: A static method to check whether the providedString
is a valid Swift code. SourcedigitCount
: A static method to count (if any) digits in theString
isAscii
: A static method to check whether aString
is consisted only from ASCII charactersisAnagramOf(String s)
: A static method to check whether the provideds
String
is anagram of the extendedString
isPalindrome
: A static method to check whether theString
is palindromeisMixedCase
: A static method to check whether theString
is consisted of both upper & lower case letters
- Optimizes
replaceGreek
method - Optimizes
toGreekUppercase
method - Optimizes
getLevenshtein
by using Wagner-Fisher algorithm
isIban
: A static method to check whether the providedString
is a valid IBAN. SourceisGreekId
: A static method to check whether the providedString
is a valid Greek Identification Number. SourceisLowerCase
: Checks whether theString
is in upper caseisUpperCase
: Checks whether theString
is in lower caseswapCase()
: Swaps the case in theString
.
String foo = 'Hello World';
String swapped = foo.swapCase(); // returns 'hELLO wORLD'
Updates project dependencies, to improve pub.dev score.
toGreekUpperCase()
: Properly uppercases Greek letters, removing the tones.
String greek = 'Τι κάνεις πώς τα περνάς φίλτατέ μου';
String wrongUpperCase = greek.toUpperCase(); // returns 'ΤΙ ΚΆΝΕΙΣ ΠΏΣ ΤΑ ΠΕΡΝΆΣ ΦΊΛΤΑΤΈ ΜΟΥ'
String correctUpperCase = greek.toGreekUpperCase(); // returns 'ΤΙ ΚΑΝΕΙΣ ΠΩΣ ΤΑ ΠΕΡΝΑΣ ΦΙΛΤΑΤΕ ΜΟΥ'
- Fixes
truncate(length)
method. If theString
is equal tolength
then theString
should be returned as it is.
toLeet
: Transform theString
to 1337 alphabet. The letters are randomized since each letter can have multiple variations.
String foo = 'esentis';
String leet = foo.toLeet ; // returns '€5£п+!$'
isCreditCard
: Checks if the providedString
is a valid credit card number using Luhn algorithmremoveWhiteSpace
: Removes all white space from the providedString
.
formatFileSize
: Formats aString
representing bytes to show the proper file size.
String foo = '24117248';
String formatted = foo.formatFileSize; // returns '23 MB'
replaceAtIndex(index,replacement)
: Adds a [replacement] at the [index] of theString
.removeSpecial
: Removes all special characters from theString
. Issue #22onlyLetters
: Removes everything but characters from theString
.Issue #21
- Project depends on
crypto
(3.0.2
) due to newmd5
method wich returns the MD5 hash of theString
. - Bug fixes for various methods,
after
,before
,toTitleCase
,openCloseWrappers
,removeFirstAndLastAny
. - Various improvements.
- Fixes
titleCase
not trimming whitespaces.
- All methods will now trim the
String
before operations. toSnakeCase
: Converts aString
to snake case format.
addAfter
: Adds aString
after the first occurence of a specific pattern.addBefore
: Adds aString
before the first occurence of a specific pattern.
-
removeAfter
: Removes everything after the first occurence of a specific pattern. -
removeBefore
: Removes everything before the first occurence of a specific pattern.
Thanks to zonaro
-
wrap
: Wraps aString
between twoString
s. -
getOppositeChar
: Returns the opposite wrap char of theString
. -
isOpenWrapChar
: Check ifString
is a open wrap char:<
,{
,[
,"
,'
. -
isCloseWrapChar
: Checks ifString
is a close wrap char:>
,}
,]
,"
,'
. -
removeFirstAny
: Continuously removes from the beginning of aString
anyString
contained in [patterns]. -
removeLastAny
: Continuously removes from the end of aString
anyString
contained in [patterns]. -
removeFirstAndLastAny
: Continuously removes from the beggining and end of aString
anyString
contained in [patterns]. -
removeLastEqual
: Remove aString
from the end of other string if equal [pattern]. -
removeFirstEqual
: Remove aString
in the beginning of other string if equal [pattern]. -
removeFirstAndLastEqual
: RemoveString
from the beginning and the end ofString
if equal [pattern]. -
containsAny
: Check ifString
contains anyString
s of [list]. -
containsAll
: Check ifString
contains allString
s of [list].
Thanks to zonaro
-
isBlank
: Checks if aString
isnull
empty or contains only whitespaces. -
isNotBlank
: Checks if aString
is NOTnull
empty or contains only whitespaces. -
asIf
: Compares aString
to another and returns the first if equal, otherwise returns the second one. -
ifBlank(String default)
: Checks if aString
is blank and gives it a default value.
- Returns the
String
after a character / word.
after(String pattern)
- Returns the
String
before a character / word.
before(String pattern)
- Gets Jaro distance to check
String
similarity. The higher the number the similar the twoString
s/
getJaro(String wordToCompare)
- Converts the
String
to abool
value if possible.
tooBool
Following extension methods are now created using get
and can now being accessed without ()
.
- capitalize
- countWords
- removeNumbers
- onlyLatin
- onlyGreek
- isNull
- isIpv4
- isIpv6
- isUrl
- isDate
- isMail
- isNumber
- isStrongPassword
- isGuid
- isLatin
- isGreek
- onlyNumbers
- removeLetters
- charOccurences
- mostFrequent
- reverse
- toSlug
- toCamelCase
- toTitleCase
- toArray
- replaceGreek
- stripHtml
- hasSameCharacters
- shuffle
- Truncates
String
with "..." when more thann
characters.
truncate(int maxChars)
- Truncates
String
in the middle with "..." keeping maxn
characters.
truncateMiddle(int maxChars)
- Quotes a
String
adding " at the start & at the end.
quote
- Trims leading and trailing spaces, so as extra spaces in between words.
trimAll
- Returns the month name of the
DateTime
(inString
format).
getMonthFromDate(locale:'en')
- Returns the first day of the month from the provided
DateTime
(inString
format).
firstDayOfMonth(locale:'en')
- Returns the last day of the month from the provided
DateTime
(inString
format).
latsDayOfMonth(locale:'en')
- Returns left side of the
String
starting fromchar
.
leftOf(String char)
- Returns right side of the
String
starting fromchar
.
rightOf(String char)
-
formatWithMask
now accepts optional parameterspecialChar
which defaults to '#' -
Add a
String
at the beginning of yourString
.
prepend(String prefix)
- Adds
-
operator subtracting a text from aString
- Returns the day name of the
DateTime
(inString
format).
String date = '2021-10-23';
String day = date.getDayFromDate(); // returns 'Saturday'
String grDay = date.getDayFromDate(locale:'el'); // returns 'Σάββατο'
- Removes the first
n
characters of theString
.
removeFirst(int n)
- Removes the last
n
characters of theString
.
removeLast(int n)
- Trims the
String
to have exactlyn
characters. Ifn
is larger than theString
length, the sameString
is returned.
maxChars(int n)
- Reverses slash provided the slash direction (
int
). 0 for / to \ and 1 for \ to /.
reverseSlash(int direction)
- Returns the character at
index
.
charAt(int index)
- Checks if a string is
null
.
isNull()
- Do something if a string is
null
.
ifNull(Function())
- Provide default value if a string is
null
.
defaultValue(String defaultValue)
- Append a
String
at the end of yourString
.
append(String suffix)
- Formats the
String
to properly show currency amount.
toPriceFormat({String? currencySymbol})
- Returns only the Greek characters of the
String
.
onlyGreek()
- Checkes whether the
String
has only Latin characters.
isLatin()
- Checkes whether the
String
has only Greek characters.
isGreek()
onlyLetters()
is nowonlyLatin()
characters.- The
countWords
extension now correctly counts only words, excluding numbers and symbols from words. For example,Hello 5 2asd friend !
word count will return 3 words.
-
Added
String?
operators>, >=, <, <=
to compareString
lengths. -
isIn(Iterable<String>)
, checks if a givenString
is in anIterable<String>
. -
formatWithMask(String mask)
, formats aString
with a specific mask.
Successfully converts library to extend String?
from String
.
Further code optimization and bug fixes.
- Converts the
String
to anum
value if possible, else returnsnull
.
toNum()
- Converts the
String
toint
if possible, else returnsnull
.
toInt()
- Converts the
String
todouble
if possible, else returnsnull
.
toDouble()
Improves and renames toStringArray (toArray now)
Adds a new extension that counts specific charater occurences in a String
.
charCount(String char)
- Squeezes a
String
to a character
squeeze(String x);
- Check if the
String
is consisted of same characters.
hasSameCharacters();
- Shuffles the word's letters.
shuffle();
- Gets the Levenshtein distance of two
String
getLevenshtein();
- Checks if a
String
is a validUrl
.
isUrl();
- Checks if a
String
is a validDate
.
isDate();
- Repeats a
String
x times
repeat(int x);
- Check if the
String
is a valid Ipv6
isIpv6();
- Check if the
String
is anum
isNumber();
- An extension that makes easier handling empty strings.
ifEmpty(()=>print('The string is empty'));
Some projects were breaking due to they depending on test_api:3.0.0 version.
Method to check whether a String
is a valid Guid
.
isGuid()
- Method to get a
List<String>
from aString
.
toStringArray()
- Method to strip all
HTML
code from aString
.
stripHtml()
- Method to check whether a
String
is a strong password.
isStrongPassword()
-
Adds isEmpty checks on all extensions.
-
Given a
String
and a pattern, finds the starting indices of all occurrences of the pattern in theString
.findPattern({required String pattern})
Useful method to normalize greek text for more performant text searches.
replaceGreek()
first({int count})
last({int count})
toSlug()
Migrates library to null
safety.
Extension added :
toTitleCase()
- Methods now correctly remove trailing and leading whitespaces from strings.
toCamelCase()
onlyNumbers()
removeLetters()
charOccurences()
mostFrequent()
reverse()
isIpv4()
readTime()
isMail()
capitalize()
removeNumbers()
onlyLetters()
countWords()