Skip to content

Commit

Permalink
feat: format in onChanged
Browse files Browse the repository at this point in the history
  • Loading branch information
VincePaulin committed Aug 22, 2024
1 parent e0a0958 commit 072becb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/pages/add_bridge/login_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,21 @@ class WhatsAppLoginForm extends StatelessWidget {
Text(L10n.of(context)!.enterYourDetails),
const SizedBox(height: 5),
IntlPhoneField(
disableLengthCheck: true,
initialCountryCode:
Localizations.localeOf(context).languageCode.toUpperCase(),
onChanged: (PhoneNumber phoneNumberField) {
controller.text = phoneNumberField.completeNumber;
String localNumber = phoneNumberField.number;

// If the local number begins with '0', it is removed
if (localNumber.startsWith('0')) {
localNumber = localNumber.substring(1);
}

// Reconstruct the complete number with the country code
controller.text = '${phoneNumberField.countryCode}$localNumber';
},

// Initial country code via language used in Locale currentLocale
languageCode: Localizations.localeOf(context).languageCode,
onCountryChanged: (country) {},
Expand Down

0 comments on commit 072becb

Please sign in to comment.