Я использую пакет flutter country_code_picker в моем TextFormField, и мне удается поместить код набора страны в текст телефона TextEditingController в моем телефоне после того, как они выбирают страну. Так, если, например, в Сенегале пользователь поставит 7712345678, я получу +2217712345678 в моем тексте контроллера TextEditing. Заранее спасибо за помощь.
вот мой код
TextEditingController phoneController = new TextEditingController(text: "");
Widget _phoneContainer() {
return new Container(
child: new TextFormField(
controller: phoneController,
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(vertical: 2),
prefixIcon: CountryCodePicker(
// Initial selection and favorite can be one of code ('IT') OR dial_code('+39')
initialSelection: '+221',
favorite: ['+221', 'SN'],
textStyle: TextStyle(color: Colors.orange[900]),
showFlag: true,
//showFlagDialog: true,
//comparator: (a, b) => b.name.compareTo(a.name),
//Get the country information relevant to the initial selection
//onInit: (code) => print("${code.name} ${code.dialCode}"),
),
labelText: Texts.PHONE_NUMBER_LOGIN,
focusColor: Colors.orange[900],
labelStyle: TextStyle(fontSize: 15.0, color: Colors.orange[900]),
/* hintStyle: TextStyle(
color: Colors.orange[900]
) */
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0)),
borderSide: const BorderSide(color: Colors.white)
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0)),
borderSide: const BorderSide(color: Colors.white)
),
hasFloatingPlaceholder: false
),
keyboardType: TextInputType.phone,
style:TextStyle(
color: Colors.orange[900],
decorationColor: Colors.white,
),
),
margin: EdgeInsets.only(bottom: 20.0, left: 40.0, right: 40.0),
color: Colors.white,
height: 40.0,
);
}