register 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 62

Package for consistently representing identifiers, usually in a code generation setting.


PurposeGetting StartedCredits

Purpose #

The purpose of the library is to have a standard way of generating an object, an Id, that can be used in any of a variety of casing contexts.

Getting Started #

For example, suppose you are writing a code generator that has a need for a single id with multiple representations. The following representations are covered:

  • snake case: words are all lower case with underscores (how_now_brown_cow)
  • emacs: words are all lower with hyphens (how-now-brown-cow)
  • shout: words are all upper case with underscores (HOW_NOW_BROWN_COW)
  • camel: words are joined with each word capitalized excluding the first (howNowBrownCow)
  • capCamel: words are joined with all words capitalized (HowNowBrownCow)
  • title: All words capitalized and joined with spaces (How Now Brown Cow)
  • squish: Lower case with no hypens or underscores (hownowbrowncow)
  • abbrev: The abbreviation in lower case (hnbc)

The default constructor requires the identifier to be snake case:

final id = Register('how_now_brown_cow');

print(id);                   // => howNowBrownCow        
print(id.snake);             // => how_now_brown_cow     
print(id.emacs);             // => how-now-brown-cow     
print(id.shout);             // => HOW_NOW_BROWN_COW     
print(id.camel);             // => howNowBrownCow        
print(id.capCamel);          // => HowNowBrownCow        
print(id.title);             // => How Now Brown Cow     
print(id.squish);            // => hownowbrowncow        
print(id.abbrev);            // => hnbc                  

An library function accepts either snake or any camel and returns a new Id:

var id = idFromString('testName');

And... api reference available here

Credits #

This software is cloning package incompatible with Dart 2:

1.0.1 #

  • Updated package description

1.0.0 #

  • Initial release


import 'package:register/register.dart';

void main() {
  final register = Register('how_now_brown_cow');
  print(register); // => howNowBrownCow
  print(register.snake); // => how_now_brown_cow
  print(register.emacs); // => how-now-brown-cow
  print(register.shout); // => HOW_NOW_BROWN_COW
  print(register.camel); // => howNowBrownCow
  print(register.capCamel); // => HowNowBrownCow
  print(register.title); // => How Now Brown Cow
  print(register.squish); // => hownowbrowncow
  print(register.abbrev); // => hnbc

Use this package as a library

1. Depend on it

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

  register: ^1.0.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:register/register.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 16, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
collection ^1.14.11 1.14.12
quiver ^2.0.3 2.1.2+1
Transitive dependencies
matcher 0.12.6
meta 1.1.8
path 1.6.4
stack_trace 1.9.3
Dev dependencies
pedantic ^1.5.0
test ^1.5.3