Overview
The Strings package is an evolution of work originally produced by Andrew Mezoni.
The purpose of the Strings package is to provide:
Complement Dart's core
Stringclass with common string utilities.Add extension methods to non-null strings where useful.
Provide static methods for values that may be null.
Wrap many core
Stringmethods for nullable input.
A core objective is to handle null input predictably. Some methods still throw for invalid indexes or missing delimiters; their pages describe those cases.
import 'package:strings/strings.dart';
// pass a short string and we can pad it (or not).
Strings.right('one', 4, pad: Pad.left);
// ' one'
// passing null works too.
Strings.right(null, 4, pad: Pad.left);
// ' 'Sponsored by OnePub
Strings is sponsored by OnePub, the private Dart repository service.
OnePub lets you privately share Dart packages with your team and customers.
Try it for free and publish your first private package in seconds.

Publish a private package in five commands:
flutter pub global activate onepub
onepub login
cd <my package>
onepub pub private
dart pub publish
Namespace
The package groups nullable utility methods as statics on Strings rather than as global functions.
This makes them easy to find with IDE completion: type Strings. to see the available methods.
Use Strings.methodName(...) for nullable values:
Nullable strings
Most Dart strings are non-null, but some values have type String?. Strings methods let you work with those values directly.
If you need to trim a String?, you can use the nullable wrapper:
For a non-null String, use its existing method or one of this package's extensions:
Utility methods
The manual follows the existing groups:
Blank checks whitespace and provides fallbacks.
Empty checks zero-length strings and handles null values.
Parts takes, pads, joins, masks, counts and extracts text.
Safe wraps core
Stringmethods for nullable input.Style checks or changes letter case and whitespace.
Transform reverses, escapes and normalizes text.
Type checks numeric and ASCII content and compares values.
Common calls include:
Extensions to String
The StringEx extension adds methods to non-null String values. The corresponding Strings statics accept nullable input when their signatures use String?:
Available extensions
StringEx adds these methods to non-null strings. Each has a corresponding Strings static method that accepts a nullable receiver.
Blank and type checks:
isBlank,isNotBlank,isLowerCase,isUpperCase,isNumeric,isAscii,startsWithLowerCase,startsWithUpperCase,equalsIgnoreCase.Parts:
abbreviate,countMatches,left,right,removePrefix,removeSuffix,partition,lastPartition,substringAfter,substringAfterLast,substringBeforeLast.Style and transform:
toCamelCase,toCapitalised,toProperCase,toSnakeCase,reverse,normalizeSpace,replaceLineEndings,toEscaped,toPrintable.
Complete method index
These are the public static methods on Strings. Follow each group link for signatures, examples and edge cases. Pad.left, Pad.right and Pad.none are described under Pad.
Blank
isBlank, isNotBlank, orElseOnBlank.
Empty
isEmpty, isNotEmpty, orElse, orElseCall, toEmpty.
Parts
abbreviate, countMatches, hidePart, join, lastPartition, left, partition, removePrefix, removeSuffix, right, substringAfter, substringAfterLast, substringBeforeLast, upTo, within.
Safe
allMatches, codeUnitAt, codeUnits, compareTo, contains, endsWith, indexOf, lastIndexOf, length, matchAsPrefix, padLeft, padRight, replaceAll, replaceAllMapped, replaceFirst, replaceFirstMapped, replaceRange, runes, split, splitMapJoin, startsWith, substring, toLowerCase, toUpperCase, trim, trimLeft, trimRight.
Style
isLowerCase, isPrintable, isUpperCase, isWhitespace, isWhitespaceRune, startsWithLowerCase, startsWithUpperCase, toCamelCase, toCapitalised, toLowerCase, toProperCase, toSnakeCase, toUpperCase.
Transform
conjuctionJoin, normalizeSpace, replaceLineEndings, reverse, toEscaped, toPrintable, toUnicode.
Type
equals, equalsIgnoreCase, isAscii, isDigits, isNumeric.
toLowerCase and toUpperCase appear under both Safe and Style, because they are nullable wrappers for core String methods and common case conversions.
Contributing
Contributions are welcome in the Strings GitHub repository. Follow the existing code layout when adding a method.
Unit Tests
Include focused unit tests for each new function.
Last updated