Skip to content

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

License

Notifications You must be signed in to change notification settings

Jesway/dart_casing

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages