Skip to content

Deleting entered value all at once returns NaN #160

@gokhancvs

Description

@gokhancvs

Hello,

When the user selects the whole number and tries the delete it by pressing delete button, it fails and returns NaN instead of something like zero.

delete_issue.mp4

Minimal code example:

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'),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions