From 668ae9cd70dd4e01d94e85cddbdacc24994f4d8c Mon Sep 17 00:00:00 2001 From: Khushboo1702 Date: Fri, 15 Mar 2024 00:08:08 +0530 Subject: [PATCH 1/4] feat(utils): implementation of number system --- lib/src/utils/number_system.dart | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lib/src/utils/number_system.dart diff --git a/lib/src/utils/number_system.dart b/lib/src/utils/number_system.dart new file mode 100644 index 0000000..7dfb3cc --- /dev/null +++ b/lib/src/utils/number_system.dart @@ -0,0 +1,29 @@ +import 'package:fa_dart_core/fa_dart_core.dart'; +import 'package:intl/intl.dart'; + +final pattern = NumberFormat('##,###.0#', 'en_US'); +const decimalPlace = 2; + +class NumberSystem { + + String parse(bool usesInternationalNumberSystem, num? val, {int decimalPlaces = 0}) => + usesInternationalNumberSystem + ? _parseAsInternational(val ?? 0, decimalPlaces: decimalPlaces) + : _parseAsIndian(val ?? 0, decimalPlaces: decimalPlaces); + + String _parseAsInternational(num val, {int decimalPlaces = 0}) { + return formatValue( + val.toDouble(), + locale: 'en_US', + decimalPlaces: decimalPlaces, + ); + } + + String _parseAsIndian(num val, {int decimalPlaces = 0}) { + return formatValue( + val.toDouble(), + locale: 'en_IN', + decimalPlaces: decimalPlaces, + ); + } +} From dad0b089453d1ab472f6c92d88dc3b49c11f5af2 Mon Sep 17 00:00:00 2001 From: Khushboo1702 Date: Tue, 19 Mar 2024 13:31:57 +0530 Subject: [PATCH 2/4] fix(number-system): changing name of the file --- ...r_system.dart => number_system_utils.dart} | 4 +-- pubspec.lock | 34 +++++++++---------- 2 files changed, 18 insertions(+), 20 deletions(-) rename lib/src/utils/{number_system.dart => number_system_utils.dart} (86%) diff --git a/lib/src/utils/number_system.dart b/lib/src/utils/number_system_utils.dart similarity index 86% rename from lib/src/utils/number_system.dart rename to lib/src/utils/number_system_utils.dart index 7dfb3cc..53d24bc 100644 --- a/lib/src/utils/number_system.dart +++ b/lib/src/utils/number_system_utils.dart @@ -1,10 +1,8 @@ import 'package:fa_dart_core/fa_dart_core.dart'; -import 'package:intl/intl.dart'; -final pattern = NumberFormat('##,###.0#', 'en_US'); const decimalPlace = 2; -class NumberSystem { +class NumberSystemUtils { String parse(bool usesInternationalNumberSystem, num? val, {int decimalPlaces = 0}) => usesInternationalNumberSystem diff --git a/pubspec.lock b/pubspec.lock index 35479e7..b447eb0 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,18 +5,18 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051 + sha256: ae92f5d747aee634b87f89d9946000c2de774be1d6ac3e58268224348cd0101a url: "https://pub.dev" source: hosted - version: "64.0.0" + version: "61.0.0" analyzer: dependency: transitive description: name: analyzer - sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893" + sha256: ea3d8652bda62982addfd92fdc2d0214e5f82e43325104990d4f4c4a2a313562 url: "https://pub.dev" source: hosted - version: "6.2.0" + version: "5.13.0" ansicolor: dependency: transitive description: @@ -102,10 +102,10 @@ packages: dependency: transitive description: name: file - sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" url: "https://pub.dev" source: hosted - version: "7.0.0" + version: "6.1.4" frontend_server_client: dependency: transitive description: @@ -350,26 +350,26 @@ packages: dependency: "direct dev" description: name: test - sha256: "9b0dd8e36af4a5b1569029949d50a52cb2a2a2fdaa20cebb96e6603b9ae241f9" + sha256: "13b41f318e2a5751c3169137103b60c584297353d4b1761b66029bae6411fe46" url: "https://pub.dev" source: hosted - version: "1.24.6" + version: "1.24.3" test_api: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.6.0" test_core: dependency: transitive description: name: test_core - sha256: "4bef837e56375537055fdbbbf6dd458b1859881f4c7e6da936158f77d61ab265" + sha256: "99806e9e6d95c7b059b7a0fc08f07fc53fabe54a829497f0d9676299f1e8637e" url: "https://pub.dev" source: hosted - version: "0.5.6" + version: "0.5.3" typed_data: dependency: transitive description: @@ -390,10 +390,10 @@ packages: dependency: transitive description: name: watcher - sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + sha256: "6a7f46926b01ce81bfc339da6a7f20afbe7733eff9846f6d6a5466aa4c6667c0" url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.0.2" web_socket_channel: dependency: transitive description: @@ -406,10 +406,10 @@ packages: dependency: transitive description: name: webkit_inspection_protocol - sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" + sha256: "67d3a8b6c79e1987d19d848b0892e582dbb0c66c57cc1fef58a177dd2aa2823d" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.2.0" yaml: dependency: transitive description: @@ -419,4 +419,4 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.0.0 <4.0.0" + dart: ">=2.19.0 <3.0.0" From cd98251412e7e6b268ff583bbad22f25257f5efb Mon Sep 17 00:00:00 2001 From: Khushboo1702 Date: Tue, 19 Mar 2024 13:35:30 +0530 Subject: [PATCH 3/4] fix(utils): formatting code --- lib/src/utils/number_system_utils.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/utils/number_system_utils.dart b/lib/src/utils/number_system_utils.dart index 53d24bc..c1337b3 100644 --- a/lib/src/utils/number_system_utils.dart +++ b/lib/src/utils/number_system_utils.dart @@ -3,8 +3,8 @@ import 'package:fa_dart_core/fa_dart_core.dart'; const decimalPlace = 2; class NumberSystemUtils { - - String parse(bool usesInternationalNumberSystem, num? val, {int decimalPlaces = 0}) => + String parse(bool usesInternationalNumberSystem, num? val, + {int decimalPlaces = 0}) => usesInternationalNumberSystem ? _parseAsInternational(val ?? 0, decimalPlaces: decimalPlaces) : _parseAsIndian(val ?? 0, decimalPlaces: decimalPlaces); From be71086aa1b656df5a5c1b8bd9020c2d6c0655ba Mon Sep 17 00:00:00 2001 From: Khushboo1702 Date: Tue, 19 Mar 2024 14:08:10 +0530 Subject: [PATCH 4/4] fix(number-system): removing unnecessary variable --- lib/src/utils/number_system_utils.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/src/utils/number_system_utils.dart b/lib/src/utils/number_system_utils.dart index c1337b3..0bc8f57 100644 --- a/lib/src/utils/number_system_utils.dart +++ b/lib/src/utils/number_system_utils.dart @@ -1,7 +1,5 @@ import 'package:fa_dart_core/fa_dart_core.dart'; -const decimalPlace = 2; - class NumberSystemUtils { String parse(bool usesInternationalNumberSystem, num? val, {int decimalPlaces = 0}) =>