From b8639baaf147970781b3450008c9d15568048066 Mon Sep 17 00:00:00 2001 From: CowboyGH Date: Sat, 13 Jun 2026 17:40:17 +0700 Subject: [PATCH] fix(subscriptions): force uppercase on payment card holder input --- .../widgets/subscription_payment_dialog.dart | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/features/subscriptions/presentation/widgets/subscription_payment_dialog.dart b/lib/features/subscriptions/presentation/widgets/subscription_payment_dialog.dart index 49a33af..0cd9f70 100644 --- a/lib/features/subscriptions/presentation/widgets/subscription_payment_dialog.dart +++ b/lib/features/subscriptions/presentation/widgets/subscription_payment_dialog.dart @@ -62,6 +62,8 @@ class _SubscriptionPaymentDialogState extends State { bool _rememberData = false; + String get _normalizedCardHolder => _cardHolderController.text.trim().toUpperCase(); + @override void initState() { super.initState(); @@ -115,7 +117,7 @@ class _SubscriptionPaymentDialogState extends State { subscriptionId: widget.item.id, saveCard: _rememberData, cardNumber: _cardNumberController.text.replaceAll(RegExp(r'\D'), ''), - cardHolder: _cardHolderController.text.trim(), + cardHolder: _normalizedCardHolder, expiryMonth: _expiryMonthController.text.trim(), expiryYear: _buildBackendExpiryYear(expiryYear), cvv: _cvvController.text.trim(), @@ -176,6 +178,7 @@ class _SubscriptionPaymentDialogState extends State { enabled: !isInProgress, keyboardType: TextInputType.name, textInputAction: TextInputAction.next, + inputFormatters: [const _CardHolderTextInputFormatter()], validator: SubscriptionPaymentValidators.cardHolder, ), const SizedBox(height: 12), @@ -300,7 +303,7 @@ class _SubscriptionPaymentDialogState extends State { right: 0, child: _PaymentPreviewCard( previewCardNumber: _previewCardNumberController.text, - cardHolder: _cardHolderController.text, + cardHolder: _normalizedCardHolder, expiryMonth: _expiryMonthController.text.trim(), expiryYear: _expiryYearController.text.trim(), ), @@ -540,6 +543,18 @@ final class _CardNumberTextInputFormatter extends TextInputFormatter { } } +final class _CardHolderTextInputFormatter extends TextInputFormatter { + const _CardHolderTextInputFormatter(); + + @override + TextEditingValue formatEditUpdate( + TextEditingValue oldValue, + TextEditingValue newValue, + ) { + return newValue.copyWith(text: newValue.text.toUpperCase()); + } +} + final class _ExpiryYearTextInputFormatter extends TextInputFormatter { const _ExpiryYearTextInputFormatter();