phone_number_controller 1.0.4 copy "phone_number_controller: ^1.0.4" to clipboard
phone_number_controller: ^1.0.4 copied to clipboard

A TextEditingController formatting international phone numbers as you type them.

example/lib/main.dart

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

void main() {
  runApp(const MainApp());
}

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'PhoneNumberController example',
      home: PhoneNumberControllerPage(),
    );
  }
}

class PhoneNumberControllerPage extends StatefulWidget {
  const PhoneNumberControllerPage({Key? key}) : super(key: key);

  @override
  PhoneNumberControllerPageState createState() =>
      PhoneNumberControllerPageState();
}

class PhoneNumberControllerPageState extends State<PhoneNumberControllerPage> {
  final _controller = PhoneNumberController(countryCode: 'us');

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('PhoneNumberController example')),
      body: Center(
          child: Padding(
        padding: const EdgeInsets.all(8.0),
        child: TextFormField(
          controller: _controller,
          keyboardType: TextInputType.phone,
          decoration: const InputDecoration(
            labelText: 'Phone number',
            hintText: 'Enter phone number',
            border: OutlineInputBorder(),
          ),
        ),
      )),
    );
  }
}
8
likes
160
points
24
downloads

Publisher

verified publisherquis.co

Weekly Downloads

A TextEditingController formatting international phone numbers as you type them.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, libphonenumber

More

Packages that depend on phone_number_controller