{"id":15066423,"url":"https://github.com/ivangalkindeveloper/phone_number_mask_parser","last_synced_at":"2026-01-11T13:38:52.730Z","repository":{"id":63039751,"uuid":"564758241","full_name":"ivangalkindeveloper/phone_number_mask_parser","owner":"ivangalkindeveloper","description":"☎️ The package provides a simple parsing of phone numbers and various masking options.","archived":false,"fork":false,"pushed_at":"2024-12-29T18:27:49.000Z","size":124,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-12T12:44:27.547Z","etag":null,"topics":["dart","dart-library","dart-package","dartlang","flutter","flutter-library","flutter-package","phone","phone-mask","phone-masking","phone-number","phone-number-mask","phone-number-masking","phone-number-parse","phone-number-parser","phone-number-parsing","phone-parse","phone-parser"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ivangalkindeveloper.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-11-11T12:34:42.000Z","updated_at":"2024-12-29T18:27:52.000Z","dependencies_parsed_at":"2023-02-16T01:31:32.029Z","dependency_job_id":"b0e43047-e6e5-4f2e-91ad-8fee751315dd","html_url":"https://github.com/ivangalkindeveloper/phone_number_mask_parser","commit_stats":{"total_commits":42,"total_committers":5,"mean_commits":8.4,"dds":"0.47619047619047616","last_synced_commit":"ca1176c4fa976500ad628882bfa67840c07806d6"},"previous_names":["ivangalkindeveloper/phone_number_mask_parser","ivangalkindeveloper/phone_number_mask"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ivangalkindeveloper/phone_number_mask_parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangalkindeveloper%2Fphone_number_mask_parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangalkindeveloper%2Fphone_number_mask_parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangalkindeveloper%2Fphone_number_mask_parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangalkindeveloper%2Fphone_number_mask_parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivangalkindeveloper","download_url":"https://codeload.github.com/ivangalkindeveloper/phone_number_mask_parser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangalkindeveloper%2Fphone_number_mask_parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271749088,"owners_count":24814122,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dart","dart-library","dart-package","dartlang","flutter","flutter-library","flutter-package","phone","phone-mask","phone-masking","phone-number","phone-number-mask","phone-number-masking","phone-number-parse","phone-number-parser","phone-number-parsing","phone-parse","phone-parser"],"created_at":"2024-09-25T01:07:57.939Z","updated_at":"2026-01-11T13:38:52.723Z","avatar_url":"https://github.com/ivangalkindeveloper.png","language":"Dart","funding_links":["https://www.buymeacoffee.com/ivangalkin"],"categories":[],"sub_categories":[],"readme":"# Phone number mask parser\n\n\u003cdiv align=\"center\"\u003e\n  ☎️ The package provides a simple parsing of phone numbers and various masking options.\n  \u003cbr\u003e\n  \u003cbr\u003e\n\n  \u003ca href=\"\"\u003e![Pub Likes](https://img.shields.io/pub/likes/phone_number_mask_parser?color=success)\u003c/a\u003e\n  \u003ca href=\"\"\u003e![Pub Version](https://img.shields.io/pub/v/phone_number_mask_parser?color=important)\u003c/a\u003e\n  \u003ca href=\"https://opensource.org/licenses/MIT\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-MIT-blue.svg\" alt=\"License: MIT\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://www.buymeacoffee.com/ivangalkin\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" height=\"32px\" width= \"128px\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n## Motivation\nSome server APIs provide unformatted phone numbers, while the application client must figure out what mask to apply to a given phone number and use it for display.\n\n## Benefits\nSome packages only provide the ability to either parse phone numbers, without the ability to apply a custom mask, or are formatters for fields from which logic cannot be extracted for use on non-field strings.\\\nThis package can use for self phone field formatters.\\\nIn the list of constant countries, such data is collected to ensure the maximum match for parsing phone numbers.\n\n## Efficiency\nDetermining the country by the potential telephone code using hash table - O(1).\\\nOverlaying a target or recognized country mask - O(N).\\\n(N - length of the recognized phone number string)\n\n## Phone code list\nThe list of countries and phone codes used may not contain all combinations of alternative codes for recognition.\\\nIf you are sure that your phone number and alternative code are definitely used in the desired country, inform the package developer.\n\n## Usage\n### Main Class\nThe package has the only main class to use - [PhoneNumberMaskParser](https://github.com/ivangalkindeveloper/phone_number_mask_parser/blob/master/lib/src/phone_number_mask_parser.dart#L10):\nThe used masks must be formatted with \"#\" symbol, for example: \"+## (##) ####\".\n\n```dart\nconst PhoneNumberMaskParser phoneNumberMaskParser = PhoneNumberMaskParser(\n    targetMask: \"+## #### ######\",\n    defaultMask: \"+### (###) ### ####\",\n    isPlus: false,\n    isEndless: true,\n);\n```\n\n| Data type | Name | Description | Default value |\n|-----------|------|-------------|---------------|\n| **String?** | **targetMask** | The mask that will be used to bypass phone number parsing to overlay all phone numbers. Use this field to use only one mask for all phone numbers. | **null** |\n| **String?** | **defaultMask** | The mask that will be used in case the phone number is not recognized. If this field is not specified, the class will use the default mask \"+### ### #### ####\". | **\"+### ### #### ####\"** |\n| **bool** | **isPlus** | The flag responsible for the plus sign at the very beginning. | **true** |\n| **bool** | **isEndless** | the flag that doesn't cut the last part of the phone number if it exceeds the length of the mask. | **false** |\n\n### Main Method\nThe main method [apply](https://github.com/ivangalkindeveloper/phone_number_mask_parser/blob/master/lib/src/phone_number_mask_parser.dart#L35) does all the masking or parsing work.\n\n### Parsing\nIf the target mask is not specified, then the method works in number parsing mode:\n\n```dart\n  const PhoneNumberMaskParser phoneNumberMaskParser = PhoneNumberMaskParser();\n  final PhoneNumberMaskParserResult result = phoneNumberMaskParser.apply(\n    phoneNumber: \"4492330323912034\",\n  );\n  print(result.phoneNumberMasked); // +44 9233 032391\n  print(result.country?.title); // United Kingdom\n  print(result.country?.iso2Code); // GB\n  print(result.country?.phoneCode); // 44\n  print(result.country?.alternativePhoneCodes); // []\n  print(result.country?.mask); // +## #### ######\n```\n\n### Masking\nTo apply your own mask, specify the target mask:\n\n```dart\n  const PhoneNumberMaskParser phoneNumberMaskParser = PhoneNumberMaskParser(\n    targetMask: \"+## ## (####) ####\",\n  );\n  final PhoneNumberMaskParserResult result = phoneNumberMaskParser.apply(\n    phoneNumber: \"930293023049495565\",\n  );\n  print(result.phoneNumberMasked); // +93 02 (9302) 3049\n  print(result.country); // null\n```\n\n### Result\nThe result is a separate class [PhoneNumberMaskParserResult](https://github.com/ivangalkindeveloper/phone_number_mask_parser/blob/master/lib/src/domain/entity/phone_number_mask_parser_result.dart#L4) that provides the following fields:\n\n| Data type | Name | Description |\n|-----------|------|-------------|\n| **String** | **phoneNumberMasked** | Formatted phone number in mask. |\n| **PhoneNumberMaskParserCountry?** | **country** | Country of parsered phone number. |\n\nCountry of parsered phone number [PhoneNumberMaskParserCountry](https://github.com/ivangalkindeveloper/phone_number_mask_parser/blob/master/lib/src/domain/entity/phone_number_mask_parser_country.dart#L2):\n| Data type | Name | Description |\n|-----------|------|-------------|\n| **String** | **title** | Name of the country of the phone. |\n| **String** | **iso2Code** | Country code according to ISO 3166 standard. |\n| **String** | **phoneCode** | Phone country code. |\n| **List\u003cString\u003e** | **alternativePhoneCodes** | Alternative phone country code. |\n| **String** | **mask** | The mask of this number in its pure form. |\n\n## Additional Objects\nAdditionally, the package provides a constant list of country objects for its own use - [PhoneNumberMaskParserConstant.countries](https://github.com/ivangalkindeveloper/phone_number_mask_parser/blob/master/lib/src/core/data/phone_number_mask_parser_constant.dart#L7).\n\n## Additional Information\nFor more details see example project.\\\nAnd feel free to open an issue if you find any bugs or errors or suggestions for adding to phone number parsing or phone countries data.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivangalkindeveloper%2Fphone_number_mask_parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivangalkindeveloper%2Fphone_number_mask_parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivangalkindeveloper%2Fphone_number_mask_parser/lists"}