From c18df5664ca47f3fd86758eaa8a2c5ac11b0314e Mon Sep 17 00:00:00 2001 From: vjrj <vjrj@comunes.org> Date: Sun, 2 Jul 2023 12:35:24 +0200 Subject: [PATCH] Update amount correctly on qr amount scanning --- lib/ui/widgets/first_screen/g1_textfield.dart | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/ui/widgets/first_screen/g1_textfield.dart b/lib/ui/widgets/first_screen/g1_textfield.dart index 357ddf6b..05c0afc2 100644 --- a/lib/ui/widgets/first_screen/g1_textfield.dart +++ b/lib/ui/widgets/first_screen/g1_textfield.dart @@ -42,12 +42,17 @@ class _G1PayAmountFieldState extends State<G1PayAmountField> { newValue != null && newValue.isNotEmpty && validate) { - context.read<PaymentCubit>().selectAmount(parseToDoubleLocalized( - locale: context.locale.toLanguageTag(), number: newValue)); + final double newAmount = parseToDoubleLocalized( + locale: context.locale.toLanguageTag(), number: newValue); + if (newAmount != context.read<PaymentCubit>().state.amount) { + context.read<PaymentCubit>().selectAmount(newAmount); + } } else { - context - .read<PaymentCubit>() - .selectAmount(newValue == null ? null : double.tryParse(newValue)); + final double? newAmount = + newValue == null ? null : double.tryParse(newValue); + if (newAmount != context.read<PaymentCubit>().state.amount) { + context.read<PaymentCubit>().selectAmount(newAmount); + } } } @@ -76,9 +81,7 @@ class _G1PayAmountFieldState extends State<G1PayAmountField> { key: _formKey, child: TextFormField( keyboardType: const TextInputType.numberWithOptions(decimal: true), - initialValue: state.amount == null - ? '' - : localizeNumber(context, state.amount!), + controller: _controller, validator: validateDecimalAndFixInitialSep, autofillHints: const <String>[], onEditingComplete: () {}, -- GitLab