Skip to content

taylanyildiz/Country-Phone-Code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

select_country_code_phone

  • for locale language change
dependencies:
  flutter:
    sdk: flutter
  flutter_localizations: # Add this line
    sdk: flutter         # Add this line
  • for country picke
country_picker: ^2.0.7
  • add material app this
import 'package:flutter_localizations/flutter_localizations.dart';
  • MaterialApp
return const MaterialApp(
 title: 'Flutter Country Phone Code Input',
 supportedLocales: [
    const Locale('en'),
    const Locale('el'),
    const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hans'), // Generic Simplified Chinese 'zh_Hans'
    const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant'), // Generic traditional Chinese 'zh_Hant'
    ],
    localizationsDelegates: [
    CountryLocalizations.delegate,
    Locale('es', ''), // Spanish, no country code
  ],
  home: HomeScreen(),
);

Country Phone Textfield

Example

CountryPhoneTextField(
    fillColor: Colors.white,
    initialCountryCode: 'TR',
    exclude: ['EN', 'FR'],
    onCountry: (country) {
    log(country!.countryCode);
    },
)

Usage

Phone input controller

  • TextEditingController textController

input validator for error

  • Function(String?)? validator;

return select country

  • Function(String? country)? phoneCode;

Focusnode for request

  • FocusNode? focusNode;

Country is like ['TR'] for TURKEY.

  • initialCountryCode;

Exclude: Can be used to exclude(remove) one or more country

from the countries list (optional).

  • List? exclude;

Input phone hintText.

  • String? hintText;

Background color

  • Color fillColor;

Style of input phone

  • TextStyle style;

Style of country phone code

  • TextStyle codeStyle;

countryListTheme: Can be used to customize the country

list's bottom sheet and widgets that lie within it. (optional).

  • final CountryListThemeData? countryListTheme;

Horizontal padding

  • double padding;

height total widget

  • double height;

Selected and inital Country flag size

  • double flagSize;

Select icon size

  • double iconSize;

Max length imput phone

  • int maxLength;