id_card_formatter 0.0.30
id_card_formatter: ^0.0.30 copied to clipboard
A Dart utility package for formatting Tanzanian IDs such as NIDA, voter ID, and national card numbers, with optional currency formatting support.
πΉπΏ ID Card Formatter #
A lightweight Flutter/Dart extension to format Tanzanian 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-XXXorT-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.1
π§ 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".genericIdFormat(format: "XXX-XXX-XXX")); // 123-456-789
print("T123456789".genericIdFormat(format: "X-XXX-XXX-XXX")); // T-123-456-789
print("123456789".genericIdFormat(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
π 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.genericIdFormat({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 πΉπΏ