From ad50bd60dade61a9c8153fdd371c1c4dd812d2e0 Mon Sep 17 00:00:00 2001 From: HBatalha <114578587+hbatalhaStch@users.noreply.github.com> Date: Mon, 11 Mar 2024 10:32:54 -0100 Subject: [PATCH] Option to exclude country selector chip from focus (#223) * add option to exclude country selector navigator chip from focus traversal * make country selector navigator chip always unfocusable --- lib/src/phone_form_field_state.dart | 38 +++++++++++++++-------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/lib/src/phone_form_field_state.dart b/lib/src/phone_form_field_state.dart index 5206aeb..14ab4b5 100644 --- a/lib/src/phone_form_field_state.dart +++ b/lib/src/phone_form_field_state.dart @@ -137,24 +137,26 @@ class PhoneFormFieldState extends FormFieldState { } Widget _buildCountryCodeChip(BuildContext context) { - return AnimatedBuilder( - animation: controller, - builder: (context, _) => CountryButton( - key: const ValueKey('country-code-chip'), - isoCode: controller.value.isoCode, - onTap: widget.enabled ? _selectCountry : null, - padding: _computeCountryButtonPadding(context), - showFlag: widget.showFlagInInput, - showIsoCode: widget.showIsoCodeInInput, - showDialCode: widget.showDialCode, - textStyle: widget.countryCodeStyle ?? - widget.decoration.labelStyle ?? - TextStyle( - fontSize: 16, - color: Theme.of(context).textTheme.bodySmall?.color, - ), - flagSize: widget.flagSize, - enabled: widget.enabled, + return ExcludeFocus( + child: AnimatedBuilder( + animation: controller, + builder: (context, _) => CountryButton( + key: const ValueKey('country-code-chip'), + isoCode: controller.value.isoCode, + onTap: widget.enabled ? _selectCountry : null, + padding: _computeCountryButtonPadding(context), + showFlag: widget.showFlagInInput, + showIsoCode: widget.showIsoCodeInInput, + showDialCode: widget.showDialCode, + textStyle: widget.countryCodeStyle ?? + widget.decoration.labelStyle ?? + TextStyle( + fontSize: 16, + color: Theme.of(context).textTheme.bodySmall?.color, + ), + flagSize: widget.flagSize, + enabled: widget.enabled, + ), ), ); }