Flutter Plugin: Thai ID Card Numbers

The Flutter plugin is a class library for Flutter programming using Dart language for coding. and Flutter is a framework for cross-platform development (iOS, Android, Windows Linux, Web) developed by Google.

This is my first Flutter plugin released on the pub.dev. I have written a Flutter plugin for validating and formatting Thai ID card numbers as users type. and this plugin is inspired by thai-id-validator.

Thai ID Card Numbers Validation

The Thai ID card numbers are 13 digits, constructed in the following format.

DigitCriteria
1This identifies the type of individual.
2 – 3The Province where the holder first registered for their ID card.
4 – 5The District where the holder first registered for their ID card.
6 – 12For Thai nationals, this will be their birth certificate number.
13A checksum calculated from digits 1-12

Usage

Import the package into the project.

import 'package:thai_id_card_numbers/thai_id_card_numbers.dart';

Declare the Thai ID card numbers object class.

final _thaiIdCardNumbers = ThaiIdCardNumbers();

For validation.

bool isVaid = _thaiIdCardNumbers.validate("1234567890123");

For formatting.

String pattern = "x-xxxx-xxxxx-xx-x";
String separator = "-";

TextFormField(
   ....
   inputFormatters: [
       ThaiIdCardNumbersFormatter(pattern: pattern, delimiter: separator),
   ],
   ....          
),

Demonstration

Next Feature

I would like to develop a new feature is generate the Thai ID card numbers for testing or whatever you want. Coming soon…

Open Source

This Flutter plugin is available to download the source code on GitHub.

Reference

Credit