caseyryan/flutter_multi_formatter

toCurrencyString() format negative amount incorrectly

Closed this issue · 0 comments

When using toCurrencyString() to format negative amount, an extra separator is appended in front.

Version: ^2.10.0

Expected behavior:
Should produce -888.00 instead of -,888.00.

Example to reproduce:

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

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final positiveString = toCurrencyString(
      '888',
      mantissaLength: 2,
    );
    final negativeString = toCurrencyString(
      '-888',
      mantissaLength: 2,
    );

    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: Scaffold(
        body: Center(
          child: Text('Positive: $positiveString\nNegative: $negativeString'),
        ),
      ),
    );
  }
}

Current Result:
Screenshot_1672805071