diff --git a/lib/ui/widgets/first_screen/pay_form.dart b/lib/ui/widgets/first_screen/pay_form.dart index 6616162f926451d8380631151b0fa07ccf72175a..2ac69efbbb393d778bf3932a964ed3dc5d344888 100644 --- a/lib/ui/widgets/first_screen/pay_form.dart +++ b/lib/ui/widgets/first_screen/pay_form.dart @@ -1,6 +1,5 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import '../../../data/models/app_cubit.dart'; @@ -69,12 +68,10 @@ class _PayFormState extends State<PayForm> { Expanded( child: TextFormField( key: _formCommentKey, - inputFormatters: <TextInputFormatter>[ - NoNewLineTextInputFormatter() - ], controller: _commentController, onChanged: (String? value) { - context.read<PaymentCubit>().setComment(value ?? ''); + final String newText = (value ?? '').replaceAll('\n', ''); + context.read<PaymentCubit>().setComment(newText); }, decoration: InputDecoration( labelText: tr('g1_form_pay_desc'), @@ -226,18 +223,3 @@ class _PayFormState extends State<PayForm> { class RetryException implements Exception { RetryException(); } - -class NoNewLineTextInputFormatter extends TextInputFormatter { - @override - TextEditingValue formatEditUpdate( - TextEditingValue oldValue, TextEditingValue newValue) { - final int cursorPosition = newValue.selection.baseOffset; - final String newText = newValue.text.replaceAll('\n', ''); - final TextSelection newSelection = - TextSelection.collapsed(offset: cursorPosition); - return TextEditingValue( - text: newText, - selection: newSelection, - ); - } -}