Package selection guidance compiled from public package information, community data, and project usage.
The change_case package extends the String class in Dart with convenient methods to convert text between various casing formats, including camelCase, PascalCase, snake_case, param-case, and CONSTANT_CASE. It simplifies string transformation tasks commonly needed in app development, such as formatting API responses, generating dynamic identifiers, or ensuring consistent naming conventions across codebases. The package is lightweight and supports all major platforms, making it ideal for cross-platform Flutter applications that require robust text manipulation.
Use cases
Formatting API response keys
Generating consistent variable names
Converting user input to standardized formats
Creating URL-friendly strings
Handling configuration key naming
Simplifying code generation workflows
Key features
Extends String with conversion methods
Supports multiple casing formats
Lightweight and easy to integrate
Cross-platform compatibility
No external dependencies
Clean, readable syntax
Suitable for
Flutter developers needing string formatting
Projects with strict naming conventions
API data processing pipelines
Code generation tools
Apps requiring URL or identifier normalization
Considerations
Does not handle complex linguistic rules
Limited to predefined casing patterns
Not suitable for advanced text processing
Requires manual handling of edge cases
No built-in validation for invalid inputs
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
Change Case
Transform a string between camelCase, PascalCase, Capital Case, snake_case, param-case, CONSTANT_CASE and others.
Transform into a string with random capitalization applied.
'Test String'.toSpongeCase(); // 'tEst stRINg'
Configuration
package:change_case has a configuration file, ChangeCaseConfig, that you can use to update splitPatterns, stripPatterns, and the placeholder which will be applied to most
function listed above.
I don't suggest changing these unless you know what you are doing 😁
Patterns
Change case uses RegExp to split & replace characters of the string.
While they are great at what they do, you may want to update or add new patterns.
These patterns can be updated by using the ChangeCaseConfig.setUp(splitPatterns: [...], stripPatterns: [...])
The default patterns are:
Note: (?:•)* is used to match any "•" (placeholder) character.
Split
ChangeCaseConfig.lowerOrNumToUpperPattern
// matches lowercase or numeric char to uppercase charRegExp('([a-z0-9])(?:•)*([A-Z])')
ChangeCaseConfig.lowerOrNumToUpperPattern
// matches uppercase char to uppercase followed by lowercase charRegExp('([A-Z])(?:•)*([A-Z][a-z])')
Strip
ChangeCaseConfig.upperToLowerPattern
// matches any non-alphanumeric charRegExp('[^A-Z0-9]+', caseSensitive: false)
ChangeCaseConfig.lowerToNumOrUpperPattern (Not included in default, but can be used to add or replace)
// matches lowercase char to numeric or uppercase char// changes the behavior to `word2019 -> word 2019` and `minifyURLs -> minify urls`RegExp('([a-z])([A-Z0-9])')