From 3e140d6310b63a160731deef7a5842a6aa9443da Mon Sep 17 00:00:00 2001 From: Nathan Anderson Date: Thu, 7 Dec 2023 16:23:11 -0700 Subject: [PATCH] 0.0.10 --- CHANGELOG.md | 1 + lib/stripe_native_card_field.dart | 14 +++++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d99f219..50e3f48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 0.0.10 - One little 'Y' I missed +- Fixed out of range error with `_adjustSelection` ## 0.0.9 diff --git a/lib/stripe_native_card_field.dart b/lib/stripe_native_card_field.dart index a6f4936..530afb9 100644 --- a/lib/stripe_native_card_field.dart +++ b/lib/stripe_native_card_field.dart @@ -1073,7 +1073,7 @@ class CardTextFieldState extends State { break; } - /// Make the selection adjustment after first frame builds + // Make the selection adjustment only on web, other platforms dont select on focus change if (kIsWeb) WidgetsBinding.instance.addPostFrameCallback((_) => _adjustSelection()); @@ -1095,27 +1095,23 @@ class CardTextFieldState extends State { switch (_currentStep) { case CardEntryStep.number: final len = _cardNumberController.text.length; - final offset = len == 0 ? 1 : len; _cardNumberController.value = _cardNumberController.value.copyWith( - selection: TextSelection(baseOffset: offset, extentOffset: offset)); + selection: TextSelection(baseOffset: len, extentOffset: len)); break; case CardEntryStep.exp: final len = _expirationController.text.length; - final offset = len == 0 ? 0 : len; _expirationController.value = _expirationController.value.copyWith( - selection: TextSelection(baseOffset: offset, extentOffset: offset)); + selection: TextSelection(baseOffset: len, extentOffset: len)); break; case CardEntryStep.cvc: final len = _securityCodeController.text.length; - final offset = len == 0 ? 0 : len; _securityCodeController.value = _securityCodeController.value.copyWith( - selection: TextSelection(baseOffset: offset, extentOffset: offset)); + selection: TextSelection(baseOffset: len, extentOffset: len)); break; case CardEntryStep.postal: final len = _postalCodeController.text.length; - final offset = len == 0 ? 0 : len; _postalCodeController.value = _postalCodeController.value.copyWith( - selection: TextSelection(baseOffset: offset, extentOffset: offset)); + selection: TextSelection(baseOffset: len, extentOffset: len)); break; } }