ID Card Formatter
A lightweight Flutter/Dart extension to format ID numbers (Generic Formatter, NIDA, Voter ID, and NCARD card style). Also supports currency formatting and customizable generic ID formats.
β¨ Features
- π Generic Formatter: Format any string using a custom pattern like
XXX-XXX-XXXorX-XXX-XXX-XXX - β
Format NIDA ID numbers like
00000000-00000-00000-00 - β
Format Tanzanian NCards (e.g. NCARD) as
XXXX XXXX XXXX XXXX - β
Format Voter IDs like
A-1234-5678-901-X - β
Format
doublevalues into currency (e.g.TZS 1,000,000)
π¦ Installation
Add this to your pubspec.yaml:
dependencies:
id_card_formatter: ^0.0.33
π§ Usage
π₯ Import
import 'package:id_card_formatter/id_card_formatter.dart';
ποΈ Generic ID Format
Format any ID using a custom pattern with 'X' as placeholders.
print("123456789".genericFormat(format: "XXX-XXX-XXX")); // 123-456-789
print("T123456789".genericFormat(format: "X-XXX-XXX-XXX")); // T-123-456-789
print("123456789".genericFormat(format: "XXX XXX XXX")); // 123 456 789
Use this when you need flexibility to support custom ID formats.
π° Currency Format
double amount = 2500000;
print(amount.toFormat()); // TZS 2,500,000
print(amount.toFormat(decimalDigits: 2)); // TZS 2,500,000.00
print(amount.toFormat(symbol: '\$')); // $ 2,500,000
print(amount.toFormat(locale: 'de_DE', symbol: 'β¬')); // β¬ 2.500.000
π PHONE NUMBER FORMAT
String phoneTz = '25512345789';
print(phoneTz.phoneFormat()); // (+255) 123 456 789
String phoneUs = '11234567890';
print(phoneUs.phoneFormat(pattern: '(+X) XXX XXX XXXX')); // (+1) 123 456 7890
π NIDA ID Format
String nida = '0000000000000000000';
print(nida.nidaFormat()); // 00000000-00000-00000-00
π NCard Format
String ncard = '0000000000000000';
print(ncard.tzNcardFormat()); // 0000 0000 0000 0000
π³οΈ Voter ID Format
String voter = 'A12345678901X';
print(voter.tzVoterFormat()); // A-1234-5678-901-X
π Extension Summary
String.nidaFormat()
Formats NIDA numbers:
XXXXXXXX-XXXXX-XXXXX-XX
String.tzNcardFormat()
Formats Ncard numbers:
XXXX XXXX XXXX XXXX
String.tzVoterFormat()
Formats Voter IDs:
A-1234-5678-901-X
String.genericFormat({format})
Formats using a custom pattern:
Example: "XXX-XXX-XXX" β 123-456-789
double.toFormat({locale, symbol, decimalDigits})
π€ Contributing
Pull requests and issues are welcome! Letβs make Tanzanian Flutter utilities awesome πΉπΏβ¨
id_card_formatter
π¨βπ» Author
Collaborators
π§ hmanyinja@gmail.com
π @hemmy6894
π @barakadewise
π @tfkcodes
Made with β€οΈ in Tanzania πΉπΏ