id 1.0.16

Id #

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

Build Status

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.

Examples #

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:

var id = new Id('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');

Use this package as a library

1. Depend on it

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


dependencies:
  id: ^1.0.16

2. Install it

You can install packages from the command line:

with pub:


$ pub get

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

3. Import it

Now in your Dart code, you can use:


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

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://dart.dev/dart-2#migration.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.2 <2.0.0