flutter_multi_formatter
flutter_multi_formatter copied to clipboard
Deleting entered value all at once returns `NaN`
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.
https://github.com/caseyryan/flutter_multi_formatter/assets/22430616/1a99e3ff-858a-40e6-b496-9abf3051d814
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'),
],
),
),
),
),
);
}
}