indian_formatters 0.0.1 copy "indian_formatters: ^0.0.1" to clipboard
indian_formatters: ^0.0.1 copied to clipboard

A comprehensive Flutter/Dart package for India-specific number formatting, currency, validators (PAN, Aadhaar, GST, IFSC, UPI), date utilities, and address tools. All-in-one — one import, everything included.

indian_formatters #

pub package License: MIT Platform

A comprehensive Flutter/Dart package for India-specific formatting, validation, and parsing. One import, everything included — no sub-imports needed.

Features #

Number Formatting

  • Indian numbering system (lakhs, crores, arabs)
  • Number to words (English and Hindi)
  • Compact notation (12L, 1Cr)

💰 Currency Formatting

  • ₹ symbol with Indian comma grouping
  • Amount in words (for cheques)
  • Compact currency notation

Validators

  • PAN Card (with holder type detection)
  • Aadhaar (with Verhoeff algorithm)
  • GST Number (with state extraction)
  • Mobile Number (with operator detection)
  • IFSC Code (with bank name)
  • PIN Code (with state/region)
  • Driving License
  • Voter ID (EPIC)
  • UPI ID (with provider detection)

📅 Date Formatting

  • Indian date format
  • Hindi numerals and month names
  • Fiscal year and financial quarter
  • Hindu calendar month names

🗺️ Address Utilities

  • All 28 states + 8 UTs
  • GST codes, capitals, Hindi names
  • Address formatting with copyWith support

Installation #

Add this to your pubspec.yaml:

dependencies:
  indian_formatters: ^0.0.1

Or install via command line:

flutter pub add indian_formatters

Quick Start #

import 'package:indian_formatters/indian_formatters.dart';

// Number formatting
print(1234567.toIndian());              // "12,34,567"
print(1234567.toIndianWords());         // "12 Lakh 34 Thousand 5 Hundred 67"
print(1234567.toIndianWordsHindi());    // "बारह लाख चौंतीस हज़ार..."
print(1200000.toIndianCompact());       // "12L"

// Currency formatting
print(1234567.89.toRupees());           // "₹12,34,567.89"
print(1234567.89.toRupeesWords());      // "Twelve Lakh... Rupees and Eighty-Nine Paise"
print(1234567.89.toChequeFormat());     // "... Rupees and Eighty-Nine Paise Only"

// Validators
print(IndianValidators.isPAN("ABCPE1234F"));           // true
print(IndianValidators.validateAadhaar("234567890123")); // null (valid)
print(IndianValidators.getGSTState("27AAPFU0939F1ZV")); // "Maharashtra"
print(IndianValidators.formatMobile("9876543210"));     // "+91 98765 43210"

// Date formatting
print(DateTime.now().toIndianFormat());     // "16 April 2026"
print(DateTime.now().fiscalYear());         // "FY 2025-26"
print(DateTime.now().financialQuarter());   // "Q1 FY27"

// States and address
final mh = IndianStates.byCode("MH");
print(mh?.gstCode);  // 27
print(mh?.capital);  // "Mumbai"

API Reference #

Number Formatting #

IndianNumberFormatter

// Static methods
IndianNumberFormatter.format(1234567)           // "12,34,567"
IndianNumberFormatter.formatWords(1234567)      // "12 Lakh 34 Thousand..."
IndianNumberFormatter.formatWordsHindi(1234567) // "बारह लाख..."
IndianNumberFormatter.toWords(100)              // "One Hundred"
IndianNumberFormatter.compact(1200000)          // "12L"
IndianNumberFormatter.compactFull(1200000)      // "12 Lakh"
IndianNumberFormatter.compactCrore(10000000)    // "1Cr"

Extension on num

1234567.toIndian()              // "12,34,567"
1234567.toIndianWords()         // "12 Lakh 34 Thousand..."
1234567.toIndianWordsHindi()    // "बारह लाख..."
1234567.toIndianCompact()       // "12L"
1234567.toIndianCompactFull()   // "12 Lakh"
100.toWords()                   // "One Hundred"
100.toWordsHindi()              // "एक सौ"

Currency Formatting #

IndianCurrencyFormatter

IndianCurrencyFormatter.format(1234567.89)              // "₹12,34,567.89"
IndianCurrencyFormatter.format(1234567, symbol: 'Rs. ') // "Rs. 12,34,567"
IndianCurrencyFormatter.formatWords(1234567.89)         // "Twelve Lakh... Rupees and Eighty-Nine Paise"
IndianCurrencyFormatter.formatCompact(1234567)          // "₹12L"
IndianCurrencyFormatter.forCheque(1234567.89)           // "... Rupees and Eighty-Nine Paise Only"
IndianCurrencyFormatter.parseCurrency("₹12,34,567")     // 1234567.0

Extension on num

1234567.89.toRupees()               // "₹12,34,567.89"
1234567.89.toRupeesWords()          // "Twelve Lakh... Rupees and Eighty-Nine Paise"
1234567.toRupeesCompact()           // "₹12L"
1234567.89.toChequeFormat()         // "... Rupees and Eighty-Nine Paise Only"

Validators #

IndianValidators

All validators provide two methods:

  • isX() → returns bool
  • validateX() → returns String? (null = valid, string = error message)

PAN Card

IndianValidators.isPAN("ABCPE1234F")          // true
IndianValidators.validatePAN("ABCPE1234F")    // null (valid)
IndianValidators.getPANType("ABCPE1234F")     // PANType.individual

Aadhaar

IndianValidators.isAadhaar("234567890123")    // true (with Verhoeff validation)
IndianValidators.validateAadhaar("234567...")  // null or error
IndianValidators.maskAadhaar("234567890123")   // "XXXX XXXX 0123"

GST Number

IndianValidators.isGST("27AAPFU0939F1ZV")       // true
IndianValidators.validateGST("27AAPFU0939F1ZV") // null
IndianValidators.getGSTState("27AAPFU0939F1ZV") // "Maharashtra"
IndianValidators.getGSTStateCode("27...")        // 27

Mobile Number

IndianValidators.isMobile("9876543210")          // true
IndianValidators.isMobile("+919876543210")       // true
IndianValidators.validateMobile("9876543210")    // null
IndianValidators.formatMobile("9876543210")      // "+91 98765 43210"
IndianValidators.getOperatorSeries("9876543210") // "Airtel (approx)"

IFSC Code

IndianValidators.isIFSC("SBIN0001234")          // true
IndianValidators.validateIFSC("SBIN0001234")    // null
IndianValidators.getBankFromIFSC("SBIN0001234") // "State Bank of India"

PIN Code

IndianValidators.isPincode("411001")            // true
IndianValidators.validatePincode("411001")      // null
IndianValidators.getStateFromPincode("411001")  // "Maharashtra, Goa..."

Driving License

IndianValidators.isDrivingLicense("MH01-2023-0012345")  // true
IndianValidators.validateDrivingLicense("MH01...")       // null

Voter ID

IndianValidators.isVoterID("ABC1234567")        // true
IndianValidators.validateVoterID("ABC1234567")  // null

UPI ID

IndianValidators.isUPI("someone@upi")           // true
IndianValidators.validateUPI("someone@upi")     // null
IndianValidators.getUPIProvider("someone@okaxis") // "Axis Bank"

Date Formatting #

IndianDateFormatter

IndianDateFormatter.format(DateTime.now())          // "16 April 2026"
IndianDateFormatter.formatHindi(DateTime.now())     // "१६ अप्रैल २०२६"
IndianDateFormatter.toHindiNumerals("2026")         // "२०२६"
IndianDateFormatter.toDevanagari(DateTime.now())    // "१६/०४/२०२६"
IndianDateFormatter.fiscalYear(DateTime.now())      // "FY 2025-26"
IndianDateFormatter.financialQuarter(DateTime.now()) // "Q1 FY26"
IndianDateFormatter.hinduMonthName(DateTime.now())  // "Chaitra"
IndianDateFormatter.hindiMonthName(DateTime.now())  // "अप्रैल"

Extension on DateTime

DateTime.now().toIndianFormat()        // "16 April 2026"
DateTime.now().toHindiFormat()         // "१६ अप्रैल २०२६"
DateTime.now().fiscalYear()            // "FY 2025-26"
DateTime.now().financialQuarter()      // "Q1 FY27"
DateTime.now().hinduMonthName()        // "Chaitra"

Address & States #

IndianStates

IndianStates.all                        // List of all 36 states/UTs
IndianStates.byCode("MH")              // IndianState object
IndianStates.byGSTCode(27)             // IndianState object
IndianStates.search("maha")            // [Maharashtra]

// IndianState properties
state.name          // "Maharashtra"
state.code          // "MH"
state.gstCode       // 27
state.capital       // "Mumbai"
state.isUT          // false
state.hindiName     // "महाराष्ट्र"

IndianAddressFormatter

final address = IndianAddressFormatter.format(
  line1: "123 Main St",
  line2: "Koregaon Park",
  city: "Pune",
  state: "Maharashtra",
  pincode: "411001",
);

print(address.formatted);  // Multi-line formatted address
print(address.city);       // "Pune"

// Copy with modifications
final newAddress = address.copyWith(city: "Mumbai");

Use in Flutter Forms #

All validators return String? making them perfect for TextFormField:

TextFormField(
  decoration: InputDecoration(labelText: 'PAN Card'),
  validator: IndianValidators.validatePAN,
  autovalidateMode: AutovalidateMode.onUserInteraction,
)

Platform Support #

This package supports all Dart platforms:

  • ✅ Android
  • ✅ iOS
  • ✅ Web
  • ✅ macOS
  • ✅ Windows
  • ✅ Linux

Dependencies #

Zero external dependencies (except meta for annotations). Pure Dart implementation.

Contributing #

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License #

This project is licensed under the MIT License - see the LICENSE file for details.

Author #

Created by vivekTemp250602

Acknowledgments #

  • Indian numbering system standards
  • TRAI mobile number series allocation
  • GST state codes from GSTN
  • Verhoeff algorithm for Aadhaar validation

Note: Mobile operator detection and PIN code to state mapping are approximate. For production use cases requiring exact data, consider integrating with official APIs.

4
likes
150
points
233
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A comprehensive Flutter/Dart package for India-specific number formatting, currency, validators (PAN, Aadhaar, GST, IFSC, UPI), date utilities, and address tools. All-in-one — one import, everything included.

Repository (GitHub)
View/report issues

Topics

#formatting #india #validation #utilities

License

MIT (license)

Dependencies

flutter, meta

More

Packages that depend on indian_formatters