Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Remove Numbers When Cursor is Behind Group Separator #14

Open
Johannes5000 opened this issue Aug 28, 2024 · 0 comments
Open

Remove Numbers When Cursor is Behind Group Separator #14

Johannes5000 opened this issue Aug 28, 2024 · 0 comments

Comments

@Johannes5000
Copy link

Assume the number "12,345" is entered in the text field.
If the cursor is positioned behind the group separator (e.g., "12,|345"), it is not possible to delete the content using the Backspace key.

Since the group separators are automatically inserted, I suggest that in this case, the previous digit is automatically removed—in this example, the "2"—so that the resulting number is "1,345".

Note: This is particularly an issue when the cursor is positioned before the comma (e.g., "12|,345"). If a digit is deleted, the cursor is placed after the comma (e.g., "1,|345"). At this point, the Backspace key can no longer be used.

import 'package:flutter/material.dart';
import 'package:number_text_input_formatter/number_text_input_formatter.dart';

void main() {
  runApp(const MainApp());
}

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: TextField(
            inputFormatters: [
              CurrencyTextInputFormatter(),
            ],
          ),
        ),
      ),
    );
  }
}
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant