dart_casing 3.0.1 copy "dart_casing: ^3.0.1" to clipboard
dart_casing: ^3.0.1 copied to clipboard

Dart library for changing String case style to the desired convention.

dart_casing #

pub package

The dart_casing package provides various casing utilities to convert strings between different cases. Below are the supported cases with examples:

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  dart_casing: <latest version>

Usage #

import 'package:dart_casing/dart_casing.dart';

main()
{
  var text = "Lorem-ipsum_dolor\\SIT amet";

  // Camel Case
  print(Casing.camelCase(text));                   // loremIpsumDolorSitAmet
  print(Casing.camelCase("myPascalCaseWord"));     // myPascalCaseWord
  
  // Pascal Case
  print(Casing.pascalCase(text));                  // LoremIpsumDolorSitAmet
  print(Casing.pascalCase("myCamelCaseWord"));     // MyCamelCaseWord
  
  // Title Case
  print(Casing.titleCase(text));                   // Lorem Ipsum Dolor Sit Amet
  print(Casing.titleCase("my_snake_case_word"));   // My Snake Case Word
  
  // Snake Case
  print(Casing.snakeCase(text));                   // lorem_ipsum_dolor_sit_amet
  print(Casing.snakeCase("myCamelCaseWord"));      // my_camel_case_word
  
  // Kebab Case
  print(Casing.kebabCase(text));                   // lorem-ipsum-dolor-sit-amet
  print(Casing.kebabCase("MyPascalCaseWord"));     // my-pascal-case-word
  
  // Dot Case
  print(Casing.dotCase(text));                     // lorem.ipsum.dolor.sit.amet
  print(Casing.dotCase("myCamelCaseWord"));        // my.camel.case.word
  
  // Constant Case
  print(Casing.constantCase(text));                // LOREM_IPSUM_DOLOR_SIT_AMET
  print(Casing.constantCase("myCamelCaseWord"));   // MY_CAMEL_CASE_WORD
  
  // Lower Case
  print(Casing.lowerCase(text, separator: " "));   // lorem ipsum dolor sit amet
  print(Casing.lowerCase("MY_CONSTANT_CASE_WORD"));// my constant case word
  
  // Upper Case
  print(Casing.upperCase(text, separator: " "));   // LOREM IPSUM DOLOR SIT AMET
  print(Casing.upperCase("myCamelCaseWord"));      // MY CAMEL CASE WORD
}

Notes #

  • The package handles various input formats, including CamelCase, PascalCase, snake_case, kebab-case, dot.case, Title Case, CONSTANT_CASE, and words separated by spaces or other symbols.

  • You can also specify a custom separator for titleCase, lowerCase, and upperCase methods to join the words.

Issues #

Please file any issues, bugs or feature request here.

License #

This project is licensed under the MIT License

8
likes
150
points
6.44k
downloads

Publisher

verified publisherjesway.com

Weekly Downloads

Dart library for changing String case style to the desired convention.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

More

Packages that depend on dart_casing