telephone_check 0.1.3 copy "telephone_check: ^0.1.3" to clipboard
telephone_check: ^0.1.3 copied to clipboard

This package will help you to validate if a telephone number is well written.

Telephone Check Version #

This Dart package helps you validate if a telephone number is well written according to common formats.

Features #

  • Validates phone numbers with optional country codes.
  • Supports various phone number formats including spaces, dashes, and parentheses.
  • Easy to use and integrate into any Dart or Flutter project.

Installation #

From pub.dev #

Run this command:

flutter pub add telephone_check
copied to clipboard

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
 telephone_check: ^0.1.0
copied to clipboard

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Import it Now in your Dart code, you can use:

import 'package:telephone_check/telephone_check.dart';
copied to clipboard

From GitHub Alternatively, you can install the package directly from the GitHub repository:

Add this to your package's pubspec.yaml file:

dependencies:
  telephone_check:
    git:
      url: https://github.com/yourusername/telephone_check.git
copied to clipboard

Then, run dart pub get to install the package.

Usage #

Import the package in your Dart code:

import 'package:telephone_check/telephone_check.dart';

void main() {
  String number = "+18095563254";
  if (TelephoneChecker.isValid(number)) {
    print('valid');
  } else {
    print('not valid');
  }

  var validTelephone = TelephoneChecker.isValid(number);
  if (validTelephone) {
    print('valid');
  } else {
    print('not valid');
  }
}
copied to clipboard

Examples #

Here's an example of how you might use the telephone_check package in a Flutter application:

import 'package:flutter/material.dart';
import 'package:telephone_check/telephone_check.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    String number = "1-800-555-5555";
    String resultString = '';
    if (TelephoneChecker.isValid(number)) {
      resultString = 'The number: $number you entered is valid';
    } else {
      resultString = 'The number: $number you entered is invalid';
    }

    return MaterialApp(
      title: 'Material App',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Material App Bar'),
        ),
        body: Center(
          child: Container(
            child: Text(resultString),
          ),
        ),
      ),
    );
  }
}

copied to clipboard

Supported Formats #

You can use various types of telephone numbers and codes such as:

  • +1 215-855-0889 (US)
  • +355 69 903 0544 (AL)
  • +57 333 3717545 (CO)
  • and more.

Contributing #

Contributions are welcome! If you have any suggestions, bug reports, or feature requests, please open an issue or submit a pull request on GitHub.

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Make your changes.
  4. Commit your changes (git commit -am 'Add new feature').
  5. Push to the branch (git push origin feature-branch).
  6. Create a new Pull Request.

License #

MIT

Acknowledgements #

  • Inspired by common phone number validation techniques and patterns.

Tech Stack #

Dart

Badges #

MIT License Pub Publisher

4
likes
160
points
45
downloads

Publisher

verified publisherneryad.dev

Weekly Downloads

2024.10.02 - 2025.04.16

This package will help you to validate if a telephone number is well written.

Homepage
Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on telephone_check