the_country_number_widgets 0.9.2+2 copy "the_country_number_widgets: ^0.9.2+2" to clipboard
the_country_number_widgets: ^0.9.2+2 copied to clipboard

A small widgets library for flutter for entering phone numbers with null safety (consider using version 0.9.0 to skip null safety)

example/lib/main.dart

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

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        body: SafeArea(
          child: Column(
            children: [
              TheCountryNumberInput(
                TheCountryNumber().parseNumber(iso2Code: "IN"),
                onChanged: (tn){
                  //even you can check whether its correctly parsed, not needed but library is not even 1.0
                  if(tn.isNotANumber()){
                    return;
                  }
                  if(tn.isValidLength){
                    //do something
                  }
                },
                //custom validation
                customValidator: (tn){
                  final enteredNumber = tn.number;
                  //do something
                  return null;
                },
              ),
            ],
          ),
        ),
      ),
    );
  }
}
4
likes
140
pub points
60%
popularity

Publisher

verified publisheryadunandan.xyz

A small widgets library for flutter for entering phone numbers with null safety (consider using version 0.9.0 to skip null safety)

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, the_country_number

More

Packages that depend on the_country_number_widgets