Skip to main content

imei_generator 2.0.0 copy "imei_generator: ^2.0.0" to clipboard
imei_generator: ^2.0.0 copied to clipboard

Generate random, valid 15-digit IMEI numbers for testing, and validate any IMEI with the Luhn check digit.

Generate random, valid 15-digit IMEI numbers, and validate any IMEI.

Useful for test data, form validation and mocking device identifiers. The generated numbers are random and not assigned to real devices.

Features #

  • ImeiGenerator().generate() returns a random IMEI that starts with a real Reporting Body Identifier and ends with a correct Luhn check digit.
  • isValidImei(imei) checks that a string is exactly 15 digits with a correct check digit.
  • No dependencies; works on every platform, including the web.

Installation #

dart pub add imei_generator

Usage #

import 'package:imei_generator/imei_generator.dart';

void main() {
  final imei = ImeiGenerator().generate();
  print(imei); // e.g. 356938035643809

  print(isValidImei(imei)); // true
  print(isValidImei('490154203237519')); // false: wrong check digit
}

For repeatable output, for example in tests, pass a seeded Random:

import 'dart:math';

final generator = ImeiGenerator(random: Random(42));

isValidImei does not strip separators; remove spaces or dashes first if your input may contain them.

Upgrading from 1.x #

Version 2.0 uses String instead of List<int>. See the changelog for the migration steps.

Additional information #

Found a bug or have an idea? Please open an issue.

1
likes
160
points
370
downloads

Documentation

API reference

Publisher

verified publisherzahidtekbas.com.tr

Weekly Downloads

Generate random, valid 15-digit IMEI numbers for testing, and validate any IMEI with the Luhn check digit.

Repository (GitHub)
View/report issues

Topics

#imei #luhn #generator #validation #testing

License

BSD-3-Clause (license)

More

Packages that depend on imei_generator