Skip to content

Commit

Permalink
formatting applied
Browse files Browse the repository at this point in the history
  • Loading branch information
caseyryan committed May 26, 2021
1 parent d103b04 commit c3c02c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion example/lib/pages/masked_formatter_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ class _MaskedFormatterPageState extends State<MaskedFormatterPage> {
TextButton(
onPressed: () {
setState(() {
_result = MaskedInputFormatter('000-000-000 00').applyMask(
_result =
MaskedInputFormatter('000-000-000 00').applyMask(
'12345678900',
);
});
Expand Down
13 changes: 8 additions & 5 deletions lib/formatters/phone_input_formatter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ class PhoneInputFormatter extends TextInputFormatter {
if (onlyNumbers.length == 2) {
/// хак специально для России, со вводом номера с восьмерки
/// меняем ее на 7
var isRussianWrongNumber = onlyNumbers[0] == '8' && onlyNumbers[1] == '9' ||
onlyNumbers[0] == '8' && onlyNumbers[1] == '3';
var isRussianWrongNumber =
onlyNumbers[0] == '8' && onlyNumbers[1] == '9' ||
onlyNumbers[0] == '8' && onlyNumbers[1] == '3';
if (isRussianWrongNumber) {
onlyNumbers = '7${onlyNumbers[1]}';
_countryData = null;
Expand Down Expand Up @@ -391,9 +392,10 @@ List<PhoneCountryData> getCountryDatasByPhone(String phone) {

class PhoneCountryData {
final String? country;

/// this field is used to store real phone code
/// for most countries it will be the same as internalPhoneCode
/// but there are cases when system need another internal code
/// but there are cases when system need another internal code
/// to tell apart similar phone code e.g. Russia and Kazakhstan
/// Kazakhstan has the same code as Russia +7 but internal code is 77
/// because most phones there start with 77 while in Russia it's 79
Expand Down Expand Up @@ -426,9 +428,10 @@ class PhoneCountryData {
factory PhoneCountryData.fromMap(Map value) {
final countryData = PhoneCountryData._init(
country: value['country'],
/// not all countryDatas need to separate phoneCode and

/// not all countryDatas need to separate phoneCode and
/// internalPhoneCode. In most cases they are the same
/// so we only need to check if the field is present and set
/// so we only need to check if the field is present and set
/// the dafult one if not
phoneCode: value['phoneCode'] ?? value['internalPhoneCode'],
countryCode: value['countryCode'],
Expand Down

0 comments on commit c3c02c2

Please sign in to comment.