- 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(),
);
CountryPhoneTextField(
fillColor: Colors.white,
initialCountryCode: 'TR',
exclude: ['EN', 'FR'],
onCountry: (country) {
log(country!.countryCode);
},
)
- TextEditingController textController
- Function(String?)? validator;
- Function(String? country)? phoneCode;
- FocusNode? focusNode;
- initialCountryCode;
- List? exclude;
- String? hintText;
- Color fillColor;
- TextStyle style;
- TextStyle codeStyle;
- final CountryListThemeData? countryListTheme;
- double padding;
- double height;
- double flagSize;
- double iconSize;
- int maxLength;