Skip to content

Commit 31c76ec

Browse files
authored
Simplifying the code
1 parent fa26e16 commit 31c76ec

File tree

1 file changed

+1
-21
lines changed

1 file changed

+1
-21
lines changed

lib/src/form_builder_phone_field.dart

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -344,28 +344,8 @@ class _FormBuilderPhoneFieldState
344344
if (phone.isNotEmpty) {
345345
try {
346346
final parseResult = PhoneNumber.parse(phone);
347-
Country? country;
348-
349347
final isoCode = parseResult.isoCode.name.split(".").last;
350-
351-
try {
352-
country = CountryPickerUtils.getCountryByIsoCode(isoCode);
353-
} catch (e) {
354-
// ignore
355-
}
356-
357-
if (country == null) {
358-
try {
359-
country = CountryPickerUtils.getCountryByPhoneCode(
360-
parseResult.countryCode,
361-
);
362-
} catch (e) {
363-
// ignore
364-
}
365-
}
366-
367-
if (country == null) throw Exception('Country not found');
368-
348+
Country? country = CountryPickerUtils.getCountryByIsoCode(isoCode);
369349
setState(() {
370350
_selectedDialogCountry = country!;
371351
});

0 commit comments

Comments
 (0)