phoneTextField method

Widget phoneTextField(
  1. BuildContext context,
  2. String? label,
  3. TextEditingController? controller,
  4. FocusNode focusNode,
  5. String initialPhonePrefix,
  6. dynamic onPrefixChange(
    1. String
    ), {
  7. bool isEnabled = true,
  8. Widget? trailing,
  9. dynamic onChange(
    1. String
    )?,
  10. Color? bgColor,
})

Implementation

Widget phoneTextField(
    BuildContext context,
    String? label,
    TextEditingController? controller,
    FocusNode focusNode,
    String initialPhonePrefix,
    Function(String) onPrefixChange,
    {bool isEnabled = true,
      Widget? trailing,
      Function(String)? onChange,
      Color? bgColor}) {
  return CustomTextField(label, controller, focusNode,
    enabled: isEnabled,
    suffixIcon: trailing ?? const SizedBox.shrink(),
    prefixIcon: CountryPicker(
      initialSelection: initialPhonePrefix,
      favorite: const ['+376', '+34', '+33', '+351'],
      onChanged: (country) {
        onPrefixChange(country!.countryCode ?? '');
      },
    ),
    showPrefixSeparator: true,
    inputFormatters: <TextInputFormatter>[
      LengthLimitingTextInputFormatter(12),
    ],
    keyboardType: TextInputType.phone,
    onChange: onChange,
    bgColor: bgColor,);
}