slugid 1.0.0+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 67

Slugid - Compressed UUIDv4 #

A slugid is a URL-safe base64 encoded UUID version 4 stripped of == padding bringing the total size to 22 characters.

Disclaimer: This is not an officially supported Google product.

Examples of slugids:

  • U_sWAEJnR4epXu-TK0FCYA
  • -8prq-8rTGqKl2W9SSfyDQ
  • ti8C-AKGQsq3rDjSuXe94w
  • Fum-zBhASyO50rg3mtQcD

There are two variants of slugids:

  • The Slugid.v4() variant, which is a random UUID v4.
  • The Slugid.nice() variant, which is a random UUID v4 selected such that the slugid encoding doesn't start with -.

The nice variant is nicer to use in commandline utilities, but it comes at a slight cost in entropy. For more details refer to the original implementation in javascript.

See also #

v1.0.0+1 #

  • Fixed homepage and issue_tracker in pubspec.yaml.

v1.0.0 #

  • Initial release, including most of the features available in other slugid implementations.

example/main.dart

// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import 'package:slugid/slugid.dart';

void main() {
  print('Generating 5 random slugids:');
  for (int i = 0; i < 5; i++) {
    // Using the _nice_ variant, which cannot start with dashes, this is always
    // nice if for some reason the ID might be given as commandline argument in
    // some tool some day.
    print(Slugid.nice());
  }
}

Use this package as a library

1. Depend on it

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


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

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

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
convert ^2.0.2 2.1.1
Transitive dependencies
charcode 1.1.2
typed_data 1.1.6
Dev dependencies
pedantic ^1.4.0
test ^1.5.1