Skip to content
pubscout

phone_number_mask_parser

3.1.0, released 2 years ago by an unverified publisher

Dart package for parsing phone numbers and applying various masking options.

WASM-ready
$ flutter pub add phone_number_mask_parser
Source repository

What it does

Provides a simple mechanism to parse phone numbers, determine countries and phone codes using an O(1) hash table, and apply custom or automatic masks.

AI-written summary of version 3.1.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to format raw, unformatted phone numbers received from server APIs for display.
  • You need automatic country detection and parsing based on phone codes.
  • You want to apply custom phone number masks using '#' symbols.

Skip it when

  • You need a complex form input field formatter widget that interacts directly with TextField state (though it can be used for self phone field formatters).
  • You require comprehensive global phone validation that relies on external libphonenumber data.

Strengths

  • Efficient O(1) phone code recognition using a hash table.
  • Supports custom target masks as well as automatic country-based masks.
  • No external dependencies.

Weaknesses

  • The built-in list of countries and phone codes may not contain all combinations of alternative codes.
  • Limited to string parsing and masking operations rather than an out-of-the-box TextField widget formatter.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0
const PhoneNumberMaskParser phoneNumberMaskParser = PhoneNumberMaskParser(
    targetMask: "+## #### ######",
    defaultMask: "+### (###) ### ####",
    isPlus: false,
    isEndless: true,
);

final PhoneNumberMaskParserResult result = phoneNumberMaskParser.apply(
  phoneNumber: "4492330323912034",
);

Alternatives

Packages that do the same job and could replace phone_number_mask_parser.