gtin_toolkit 1.0.3

Dart native js
Flutter Android iOS web

A toolkit for validate, generate and check GTIN's. This project indeeds to be; stable, easy to use and fast (when possible).

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
likes
110
pub points
0%
popularity

A toolkit for validate, generate and check GTIN's. This project indeeds to be; stable, easy to use and fast (when possible).

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

vinicios.dev@gmail.com

License

MIT (LICENSE)

More

Packages that depend on gtin_toolkit