Giter VIP home page Giter VIP logo

phonenumbers's Introduction

phonenumbers

Phone number validation and filed written in pure dart without any native dependency.

Package Status

โ›”๏ธ The package is not production ready.
There might be some breaking changes over time, we'll try not to break too much but keep that in your mind.

Why...?

Currently there are lots of packages available on pub.dev for working with phone numbers (inputs, validators, etc...) However, most of them are using native libraries like libphonenumber under the hood. While those libraries are very well written implementations, they are not written natively for Flutter (yet). That means flutter library maintainers are using certain communication mechanisms like platform channels or ffi to communicate with those libraries. Additional abstraction layer of communication leads to increased implementation complexity and increases points of failure.

This library however uses simplified dart-native implementation that doesn't require additional communication layer and also works synchronously / meaning you are guaranteed to get near-instant feedback (if it doesn't panic, I hope ๐Ÿคž).

That said, I am not trying to convience you that this is the best phone number utility for dart/flutter. It's just the library that got my job done during the time of writing my projects.

Getting Started

Installation

  1. Add phonenumbers: ^1.0.0 dependency to "pubspec.yaml" file
  2. Run [flutter] pub get to install package
  3. Drink a cup of coffee

Enjoy

Import phonenumbers library which exports useful classes like PhoneNumberField widget.

import 'package:phonenumbers/phonenumbers.dart';

Then you can build PhoneNumberField() widget wherever you want. It works like any other widgets.

class _MyPageState extends State<MyPage> {
  final phoneNumberController = PhoneNumberEditingController();

  @override
  void dispose() {
    phoneNumberController.dispose(); // to save environment
    super.dispose();
  }

  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        PhoneNumberField(
          controller: phoneNumberController,
          decoration: InputDecoration(),
        ),
      ],
    );
  }
}

The documentation will be improved over time...

Contribute

Found an issue, or maybe have a brilliant idea? Maybe our data is not valid. Feel free to contribute if you want ๐Ÿ˜Š

phonenumbers's People

Contributors

aumb avatar imgbotapp avatar markuspaschi avatar themisir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

phonenumbers's Issues

country code

don't able to select country code may be something wrong with the controller

phonenumbers package

First of all thanks for the package.

It's a good idea to have a pure dart version, just for the fact that it instantly support all platforms and it also reduces the file size for the web. It also doesn't really need all the fancy stuff there are in the libphonenumber library since you know what's the prefix and what isn't. That being said I think the phone number validation bit could be in a separate package from the UI. It could also use pattern matching. PhoneNumberKit (iOS) there is this metadata for pattern validation https://github.com/marmelroy/PhoneNumberKit/blob/master/PhoneNumberKit/Resources/PhoneNumberMetadata.json

I've a few ideas for the ui and I'll go ahead and post all of them in this issue, I don't expect you to implement all of them though I could help. Most of them is to get closer to the UI provided by this package, because it looks dope: https://github.com/natintosh/intl_phone_number_input

UI:

  • bottom sheet country selection
  • flags in country selection
  • option to let the search bar be initially focused

Hint number text and spaces

Hello,

Thanks a lot!

It would be awesome to add the phone pattern for each country as a hint text.

Like :

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.