CheckDigit enum

A check character computed from the data before it: gs1 for GTIN, EAN, UPC, SSCC and GLN, luhn for card and account numbers, mod43 for Code 39.

of gives the check character, append the data with it, isValid tells whether the last character of a text is the right one.

CheckDigit.gs1.of('400638133393'); // '1'
CheckDigit.gs1.append('400638133393'); // '4006381333931'
CheckDigit.gs1.isValid('4006381333931'); // true
CheckDigit.luhn.of('7992739871'); // '3'

EAN-13, EAN-8, UPC-A, UPC-E and GS1 DataBar add their check digit themselves when it is left out: give BarcodeWriter the data without one, or with the right one.

Inheritance
Available extensions

Values

gs1 → const CheckDigit

The GS1 mod 10 check digit (GS1 General Specifications 7.9.1): the digits weighted 3 and 1 from the right, the check digit makes the sum a multiple of 10. The last digit of a GTIN (EAN-13, EAN-8, UPC-A, GTIN-14), SSCC and GLN. Digits only.

luhn → const CheckDigit

The Luhn mod 10 check digit (ISO/IEC 7812): every second digit from the right doubled. The last digit of payment card numbers, IMEI and many account and membership numbers. Digits only.

mod43 → const CheckDigit

The Code 39 mod 43 check character: the values of the characters (0-9, A-Z, then -, ., space, $, /, +, %) added up, modulo 43. Capital letters, digits, space and - . $ / + % only.

Properties

hashCode → int
The hash code for this object.
no setterinherited
index → int
A numeric identifier for the enumerated value.
no setterinherited
name → String

Available on Enum, provided by the EnumName extension

The name of the enum value.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

append(String data) → String
data with its check character after it.
isValid(String text) → bool
Whether the last character of text is the check character of the rest. false for a text shorter than two characters or with a character the check does not take.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
of(String data) → String
The check character of data, without it: one digit for gs1 and luhn, one Code 39 character for mod43.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

values → const List<CheckDigit>
A constant List of the values in this enum, in order of their declaration.