flutter_multi_formatter icon indicating copy to clipboard operation
flutter_multi_formatter copied to clipboard

The value is multiplied by 100 when a number is deleted

Open gokhancvs opened this issue 1 year ago • 3 comments

Hello,

There has been an issue in this package for a long time. When the entered value is being deleted, if the cursor is just to the right of the comma and we delete to move to the left side of the comma, the entered value is multiplied by 100. The value appears correctly in the text field, but the value that returns from onValueChange is multiplied by 100.

https://github.com/caseyryan/flutter_multi_formatter/assets/22430616/e94f6566-1f22-49fc-86d1-99af623c7c07

Example code:

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

void main() => runApp(const MyApp());

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String enteredValue = '';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Padding(
          padding: const EdgeInsets.all(32),
          child: Center(
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                TextFormField(
                  autofocus: true,
                  textAlign: TextAlign.center,
                  inputFormatters: [
                    CurrencyInputFormatter(
                      onValueChange: (value) {
                        setState(() {
                          enteredValue = value.toStringAsFixed(2);
                        });
                      },
                    ),
                  ],
                ),
                const SizedBox(height: 16),
                Text('Entered Value: $enteredValue'),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

gokhancvs avatar May 31 '24 09:05 gokhancvs

Hello, any updates about this?

gokberkbar avatar Jul 04 '24 07:07 gokberkbar

I'm using this package this week, and to support the small community around it, I will try to assist the original developer. I believe I can assist with this issue next week.

I'll provide some feedback on it shortly. Keep me in touch if you found some workaround or found the whole solution

IguJl15 avatar Jul 12 '24 05:07 IguJl15

@IguJl15 Hi, thank you for the support. I did not have time to deep dive the issue. If i can find time next week I will try to find solution too. Keep in touch 👋

gokberkbar avatar Jul 13 '24 08:07 gokberkbar