id_card_formatter 0.0.33 copy "id_card_formatter: ^0.0.33" to clipboard
id_card_formatter: ^0.0.33 copied to clipboard

A lightweight Flutter/Dart extension to format ID numbers (Generic Formatter, NIDA, phone number, Voter ID, and NCARD card style). Also supports currency formatting and customizable generic ID formats..

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-XXX or X-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 double values 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 πŸ‡ΉπŸ‡Ώ

0
likes
150
points
12
downloads

Publisher

unverified uploader

Weekly Downloads

A lightweight Flutter/Dart extension to format ID numbers (Generic Formatter, NIDA, phone number, Voter ID, and NCARD card style). Also supports currency formatting and customizable generic ID formats..

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on id_card_formatter