Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix number will be changed automatically as 89 or 83 #132

Merged
merged 2 commits into from
Jul 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/formatters/phone_input_formatter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import 'phone_input_enums.dart';
class PhoneInputFormatter extends TextInputFormatter {
final ValueChanged<PhoneCountryData?>? onCountrySelected;
final bool allowEndlessPhone;
final bool shouldCorrectNumber;
final String? defaultCountryCode;

PhoneCountryData? _countryData;
Expand All @@ -44,12 +45,15 @@ class PhoneInputFormatter extends TextInputFormatter {
/// [allowEndlessPhone] if true, a phone can
/// still be enterng after the whole mask is matched.
/// use if you are not sure that all masks are supported
/// [shouldCorrectNumber] if input number is wrong in some country as Rus and Aus,
/// the phone be correctted to new number
/// [defaultCountryCode] if you set a default country code,
/// the phone will be formatted according to its country mask
/// and no leading country code will be present in the masked value
PhoneInputFormatter({
this.onCountrySelected,
this.allowEndlessPhone = false,
this.shouldCorrectNumber = true,
this.defaultCountryCode,
});

Expand Down Expand Up @@ -84,7 +88,7 @@ class PhoneInputFormatter extends TextInputFormatter {
_clearCountry();
}
}
if (onlyNumbers.length == 2) {
if (shouldCorrectNumber && onlyNumbers.length == 2) {
/// хак специально для России, со вводом номера с восьмерки
/// меняем ее на 7
var isRussianWrongNumber =
Expand Down