nanoid 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 91

nanoid #

build pub

Dart implementation of ai/nanoid

Installation #

Add nanoid as a dependency in your pubspec.yaml file

Usage #

Normal #

import 'package:nanoid/nanoid.dart';

void main() {
  var id = nanoid();
  var custom_length_id = nanoid(10);
  // ...
}

Custom Alphabet or length #

import 'package:nanoid/generate.dart';

void main() {
  var id = generate('1234567890abcdef', 10);
  // ...
}

Async API #

import 'package:nanoid/async/nanoid.dart';

void main() async {
  var id = await nanoid();
  var custom_length_id = await nanoid(10);
  // ...
}
import 'package:nanoid/async/generate.dart';

void main() async {
  var id = await generate('1234567890abcdef', 10);
  // ...
}

Non-secure API #

import 'package:nanoid/non_secure/nanoid.dart';

void main() {
  var non_secure_id = nanoid();
  var custom_length_id = nanoid(10);
  // ...
}
import 'package:nanoid/non_secure/generate.dart';

void main() {
  var non_secure_id = generate('1234567890abcdef', 10);
  // ...
}

License #

MIT

0.0.1 #

  • Initial version

0.0.2 #

  • Support customize generator

0.0.3 #

  • Add unit tests

0.0.4 #

  • Upgrade pubspec to allow Dart 2 stable

0.0.5 #

  • Update alphabet following nanoid v2
  • Add nanoid v2 non secure API

0.0.6 #

  • Add nanoid v2 async API

0.1.0 #

  • Maintenance issues and suggestions

example/nanoid_example.dart

import 'package:nanoid/nanoid.dart';

void main() {
  var id = nanoid();
  print(id);

  var custom_length_id = nanoid(10);
  print(custom_length_id);
}

Use this package as a library

1. Depend on it

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


dependencies:
  nanoid: ^0.1.0

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:nanoid/nanoid.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
82
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
91
Learn more about scoring.

We analyzed this package on Nov 8, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:nanoid/nanoid.dart.

Health issues and suggestions

Document public APIs. (-1 points)

7 out of 7 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.0 <3.0.0
Dev dependencies
test ^1.3.0