gtin_toolkit 1.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • new50

GTIN Toolkit #

pub package Dart CI

Illustrative Image

A toolkit for validate GTIN's and generate GTIN as well.

This project indeeds to be, stable, easy to use and fast (when possible).

Features #

Actually this library could make something like :

  • Validate

    GTIN including types, SSCC, GSIN, GTIN-14, GTIN-13, GTIN-12, GTIN-8.

  • Generate Random valid GTIN

    Only need give the amount of GTIN digits ex.: for SSCC use 18 digits.

  • Classify GTIN

    Return type using length for classify SSCC, GSIN, GTIN-14, GTIN-13, GTIN-12, GTIN-8.

Use Example #


import 'package:gtin_toolkit/gtin_toolkit.dart' as gtinTool;
import 'package:test/test.dart';

void main() {
  test('All methods are being exported correctly', () {
    // Generating a valid GTIN number with 12 digit length
    String validGtin = gtinTool.generateGTIN(gtinLength: 12);
    // make error replacing two right number with 1
    String invalidGtin = validGtin.padRight(10).padRight(13, '1');

    List<int> validGtinArray = validGtin.split('').map(int.parse).toList();
    List<int> invalidGtinArray = invalidGtin.split('').map(int.parse).toList();

    expect(gtinTool.parseAndValidate(validGtin), true);
    expect(gtinTool.isValidGTIN(validGtinArray), true);

    expect(gtinTool.parseAndValidate(invalidGtin), false);
    expect(gtinTool.isValidGTIN(invalidGtinArray), false);

    expect(gtinTool.generateGTIN().length, 14);
    expect(gtinTool.classifyGTIN(validGtin)['name'], 'GTIN-12');

    expect(true, true);
  });
}


1.0.2 #

  • Removed version from README.md

1.0.1 #

  • Improved project usability for pub.dev ranking system

1.0.0 #

  • Added Validator

  • Added Classifier

  • Added Generator

example/example.dart

import 'package:gtin_toolkit/gtin_toolkit.dart' as gtinTool;

void main() {
  // Generating a valid GTIN number with 12 digit length
  String validGtin = gtinTool.generateGTIN(gtinLength: 12);
  // make error replacing two right number with 1
  String invalidGtin = validGtin.padRight(10).padRight(13, '1');

  List<int> validGtinArray = validGtin.split('').map(int.parse).toList();
  List<int> invalidGtinArray = invalidGtin.split('').map(int.parse).toList();

  print('Generated GTIN:');
  print(validGtin);
  print('Generated GTIN Type:');
  print(gtinTool.classifyGTIN(validGtin));

  gtinTool.parseAndValidate(validGtin);
  gtinTool.isValidGTIN(validGtinArray);

  gtinTool.parseAndValidate(invalidGtin);
  gtinTool.isValidGTIN(invalidGtinArray);
}

Use this package as a library

1. Depend on it

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


dependencies:
  gtin_toolkit: ^1.0.3

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:gtin_toolkit/gtin_toolkit.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
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]
50
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.13

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
Dev dependencies
test 1.15.1