StringExtension extension
Extension on String to provide additional functionality and utility methods.
This extension enhances the capabilities of String by adding methods for:
- Validating string formats (e.g., email, URL, phone number)
- Manipulating string content (e.g., reversing, removing characters)
- Extracting information from strings
- Converting string formats
- Checking string properties
- File type detection
- Text formatting and truncation
- on
Properties
- countWord → int
-
Available on String, provided by the StringExtension extension
Counts the number of words in the string.no setter - fromBase64 → String?
-
Available on String, provided by the StringExtension extension
Decodes a base64 encoded string.no setter - isAlphabet → bool
-
Available on String, provided by the StringExtension extension
Checks if the string contains only alphabetic characters.no setter - isAlphaNumeric → bool
-
Available on String, provided by the StringExtension extension
Checks if the string contains only alphanumeric characters.no setter - isAudio → bool
-
Available on String, provided by the StringExtension extension
Checks if the string represents an audio file path (MP3, WAV, AAC, or M4A).no setter - isBase64 → bool
-
Available on String, provided by the StringExtension extension
Checks if the string is a valid base64 encoded string.no setter - isCapital → bool
-
Available on String, provided by the StringExtension extension
Checks if the string is in capital case.no setter - isCreditCard → bool
-
Available on String, provided by the StringExtension extension
Checks if the string is a valid credit card number.no setter - isCsv → bool
-
Available on String, provided by the StringExtension extension
Checks if the string represents a CSV file path.no setter - isDate → bool
-
Available on String, provided by the StringExtension extension
Checks if the string is a valid date in 'YYYY-MM-DD' format.no setter - isDocument → bool
-
Available on String, provided by the StringExtension extension
Checks if the string represents a document file path (PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX).no setter - isEmail → bool
-
Available on String, provided by the StringExtension extension
Checks if the string is a valid email address.no setter - isHexColor → bool
-
Available on String, provided by the StringExtension extension
Checks if the string is a valid hexadecimal color code.no setter - isHtml → bool
-
Available on String, provided by the StringExtension extension
Checks if the string contains HTML tags.no setter - isImage → bool
-
Available on String, provided by the StringExtension extension
Checks if the string represents an image file path (SVG, PNG, JPG, JPEG, GIF, WEBP, BMP, or HEIC).no setter - isIPv4 → bool
-
Available on String, provided by the StringExtension extension
Checks if the string is a valid IPv4 address.no setter - isIPv6 → bool
-
Available on String, provided by the StringExtension extension
Checks if the string is a valid IPv6 address.no setter - isJpg → bool
-
Available on String, provided by the StringExtension extension
Checks if the string represents a JPG or JPEG file path.no setter - isJson → bool
-
Available on String, provided by the StringExtension extension
Checks if the string is a valid JSON format.no setter - isLower → bool
-
Available on String, provided by the StringExtension extension
Checks if the string is in lowercase.no setter - isNumber → bool
-
Available on String, provided by the StringExtension extension
Checks if the string contains only numeric characters.no setter - isPDF → bool
-
Available on String, provided by the StringExtension extension
Checks if the string represents a PDF file path.no setter - isPhone → bool
-
Available on String, provided by the StringExtension extension
Checks if the string is a valid phone number.no setter - isPng → bool
-
Available on String, provided by the StringExtension extension
Checks if the string represents a PNG file path.no setter - isSentence → bool
-
Available on String, provided by the StringExtension extension
Checks if the string is in sentence case.no setter - isSvg → bool
-
Available on String, provided by the StringExtension extension
Checks if the string represents an SVG file path.no setter - isTime → bool
-
Available on String, provided by the StringExtension extension
Checks if the string is a valid time in 'HH:MM' format.no setter - isTitle → bool
-
Available on String, provided by the StringExtension extension
Checks if the string is in title case.no setter - isTxt → bool
-
Available on String, provided by the StringExtension extension
Checks if the string represents a TXT file path.no setter - isUpper → bool
-
Available on String, provided by the StringExtension extension
Checks if the string is in uppercase.no setter - isURL → bool
-
Available on String, provided by the StringExtension extension
Checks if the string is a valid URL.no setter - isUUID → bool
-
Available on String, provided by the StringExtension extension
Checks if the string is a valid UUID.no setter - isVideo → bool
-
Available on String, provided by the StringExtension extension
Checks if the string represents a video file path (MP4, AVI, MOV, or MKV).no setter -
occurrences
→ Map<
String, int> -
Available on String, provided by the StringExtension extension
Counts the occurrences of each character in the string.no setter - removeDigits → String
-
Available on String, provided by the StringExtension extension
Removes all digits from the string.no setter - removeHtmlTags → String
-
Available on String, provided by the StringExtension extension
Removes all HTML tags from the string.no setter - removeSpecialChars → String
-
Available on String, provided by the StringExtension extension
Removes all special characters, leaving only alphanumeric values and spaces.no setter - removeWhitespace → String
-
Available on String, provided by the StringExtension extension
Removes all whitespace from the string.no setter - reverse → String
-
Available on String, provided by the StringExtension extension
Reverses the entire string.no setter - toBase64 → String
-
Available on String, provided by the StringExtension extension
Encodes the string to base64.no setter - toCamelCase → String
-
Available on String, provided by the StringExtension extension
Converts a string to camelCase.no setter - toCapitalCase → String
-
Available on String, provided by the StringExtension extension
Converts the string to capital case (first letter of each word capitalized).no setter - toDouble → double?
-
Available on String, provided by the StringExtension extension
Converts the string to a double.no setter - toggleCase → String
-
Available on String, provided by the StringExtension extension
Toggles the case of each character in the string.no setter - toInt → int?
-
Available on String, provided by the StringExtension extension
Converts the string to an integer.no setter - toKebabCase → String
-
Available on String, provided by the StringExtension extension
Converts a string to kebab-case.no setter - toSentenceCase → String
-
Available on String, provided by the StringExtension extension
Converts the string to sentence case (first letter capitalized, rest lowercase).no setter - toSlug → String
-
Available on String, provided by the StringExtension extension
Converts the string to a URL-friendly slug.no setter - toSnakeCase → String
-
Available on String, provided by the StringExtension extension
Converts a string to snake_case.no setter - toTitleCase → String
-
Available on String, provided by the StringExtension extension
Converts the string to title case (first letter of each word capitalized, rest lowercase).no setter
Methods
-
append(
String string) → String -
Available on String, provided by the StringExtension extension
Appends the given string to the end of this string. -
concat(
String concat) → String -
Available on String, provided by the StringExtension extension
Concatenates the given string to this string, separated by a space. -
countOccurrence(
String string) → int -
Available on String, provided by the StringExtension extension
Counts the number of occurrences of a substring within this string. -
extractEmails(
) → List< String> -
Available on String, provided by the StringExtension extension
Extracts all valid email addresses from the string. -
extractUrls(
) → List< String> -
Available on String, provided by the StringExtension extension
Extracts all valid URLs from the string. -
ifEmpty(
[String value = 'null']) → String -
Available on String, provided by the StringExtension extension
Returns a default value if the string is empty. -
inRange(
int min, int max) → bool -
Available on String, provided by the StringExtension extension
Checks if the string's length is within the specified range. -
mask(
{int upto = 4, String mask = '*', bool atEnd = false}) → String? -
Available on String, provided by the StringExtension extension
Masks a portion of the string with the specified character. -
maxLen(
int max) → bool -
Available on String, provided by the StringExtension extension
Checks if the string's length is less than or equal to the specified maximum. -
minLen(
int min) → bool -
Available on String, provided by the StringExtension extension
Checks if the string's length is greater than or equal to the specified minimum. -
prepend(
String string) → String -
Available on String, provided by the StringExtension extension
Prepends the given string to the start of this string. -
regex(
String source) → bool -
Available on String, provided by the StringExtension extension
Checks if the string matches the given regex pattern. -
removeFirst(
[int? upto]) → String -
Available on String, provided by the StringExtension extension
Removes the firstupto
characters from the string. -
removeLast(
[int upto = 1]) → String -
Available on String, provided by the StringExtension extension
Removes the lastupto
characters from the string. -
truncate(
int length, {String ellipsis = '...'}) → String -
Available on String, provided by the StringExtension extension
Truncates the string to the specified length and adds an ellipsis if truncated.
Static Methods
-
isBool(
String value) → bool -
Available on String, provided by the StringExtension extension
Checks if the string represents a boolean value.