smart_phone_numb 0.2.3
smart_phone_numb: ^0.2.3 copied to clipboard
A Flutter package for a smart phone number field that automatically suggests the country code and sets the phone number length dynamically based on timezone.
Smart Phone Number Field #
A Flutter package that provides an phone number input field with automatic country code and number field lenth detection based on the user's timezone. Features
- Smart Country Detection: Automatically suggests the correct country code based on user's timezone
- Dynamic Phone Number Validation: Sets minimum and maximum phone number length limits based on the selected country
- Country Code Picker Integration: Easy-to-use country selector with flag display
- Real-time Validation: Validates phone numbers according to country-specific rules
- Support for 221+ Countries: Comprehensive database of phone number formats worldwide
Getting Started
Add this package to your pubspec.yaml:
dependencies:
smart_phone_numb: ^0.2.3
Then run:
flutter pub get
Usage
Import the package and use the SmartPhoneNumberField widget:
import 'package:flutter/material.dart';
import 'package:smart_phone_numb/smart_phone_numb.dart';
class MyForm extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Padding(
padding: EdgeInsets.all(16.0),
child: Form(
child: SmartPhoneNumberField(),
),
),
);
}
}
How It Works
- Automatic Detection: When the widget loads, it detects the user's timezone
- Country Mapping: Maps the timezone to the most likely country code
- Smart Validation: Automatically sets the correct phone number length limits
- User Override: Users can manually select a different country if needed
Example
The widget will:
- Show a country flag and code picker
- Display a text field for phone number input
- Validate the phone number length based on the selected country
- Provide real-time feedback for invalid inputs
Supported Countries
The package includes phone number validation rules for 221+ countries, covering:
- Minimum and maximum phone number lengths
- Country-specific formatting requirements
- Major international dialing codes
Dependencies
This package uses:
country_code_pickerfor the country selection UIflutter_timezonefor automatic timezone detection