string_utils_plus 0.0.1 copy "string_utils_plus: ^0.0.1" to clipboard
string_utils_plus: ^0.0.1 copied to clipboard

A comprehensive and modern Dart string manipulation library using extension methods.


string_utils_plus #

A modern and extensible Dart package providing rich string manipulation utilities as intuitive extension methods on String.


Features #

Casing and Conversion #

  • .camelToSnake() — Convert camelCase to snake_case
  • .snakeToCamel() — Convert snake_case to camelCase
  • .kebabToPascal() — Convert kebab-case to PascalCase
  • .pascalToKebab() — Convert PascalCase to kebab-case
  • .titleCase() — Convert string to Title Case
  • .capitalize() — Capitalize the first character
  • .decapitalize() — Make the first character lowercase

Formatting and Masking #

  • .slugify() — Create URL-friendly slug from string
  • .truncate(int maxLength, {String ellipsis = '...'}) — Truncate to max length with optional ellipsis
  • .removeSpecialChars({String allowedChars = ''}) — Remove special characters except allowed
  • .padLeftWith(int width, String char) — Pad left side to width with given character
  • .padRightWith(int width, String char) — Pad right side to width with given character
  • .mask({int unmaskedStart = 2, int unmaskedEnd = 2, String maskChar = '*'}) — Mask a string length except parts
  • .normalizeWhitespace() — Trim and collapse multiple spaces

Counting and Searching #

  • .containsWord(String word) — Check if string contains the exact word
  • .wordCount() — Count the words in the string
  • .charCount({bool ignoreSpaces = false}) — Count characters, optionally ignoring spaces

Validation & Checking #

  • .isUpperCase() — Check if all letters are uppercase
  • .isLowerCase() — Check if all letters are lowercase
  • .isNumeric() — Check if string contains only numbers (including negative/floats)
  • .equalsIgnoreCase(String other) — Case insensitive string equality
  • .equalsTrimmed(String other) — Equality ignoring leading/trailing whitespace
  • .isValidEmail() — Email format validation
  • .isValidUrl() — URL format validation
  • .isValidDomain() — Domain name validation
  • .isValidIPv4() — IPv4 address validation
  • .isValidIPv6() — IPv6 address validation
  • .isStrongPassword() — Password strength validation (uppercase, lowercase, digit, special char)
  • .isValidPhoneNumber() — Phone number validation (with +, spaces, dashes, parentheses)
  • .matchesRegex(String pattern) — Custom regex pattern validation

Pluralization #

  • .pluralize() — Basic English pluralization rules
  • .singularize() — Basic singularization rules

Getting Started #

Installation #

Add to your pubspec.yaml:

dependencies:
  string_utils_plus: <latest_version>

Then run:

dart pub get

or for Flutter projects:

flutter pub get

Usage #

Import the package in your Dart code:

import 'package:string_utils_plus/string_utils_plus.dart';

Examples #

void main() {
  // Casing conversions
  print('someVariableName'.camelToSnake()); // some_variable_name
  print('some_variable_name'.snakeToCamel()); // someVariableName

  // Formatting
  print('This is a long text'.truncate(10)); // This is...
  print('Hello, World!'.slugify());          // hello-world

  // Masking
  print('1234567890'.mask());                 // 12******90

  // Validation
  print('test@example.com'.isValidEmail());  // true
  print('https://flutter.dev'.isValidUrl()); // true
  print('192.168.1.1'.isValidIPv4());        // true

  // Counting and checking
  print('Count words here'.wordCount());     // 3
  print('Whitespace  count'.charCount(ignoreSpaces: true)); // 14

  // Pluralize and singularize
  print('city'.pluralize());                  // cities
  print('children'.singularize());            // children (basic rules)

  // Equality checks
  print('flutter'.equalsIgnoreCase('FlUtTeR'));  // true
  print(' spaced '.equalsTrimmed('spaced'));      // true
}

Extensibility #

The package is structured modularly with extension methods divided into separate files (casing.dart, formatting.dart, validation.dart, pluralization.dart, etc.) to facilitate easy contributions and maintenance.

Feel free to explore and extend the library to fit your string manipulation needs.


Example #

See the example/ directory for a complete usage example.


License #

See LICENSE


2
likes
160
points
7
downloads

Publisher

unverified uploader

Weekly Downloads

A comprehensive and modern Dart string manipulation library using extension methods.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on string_utils_plus