fix : sale out of Province

This commit is contained in:
2025-06-22 16:51:22 +03:30
parent 97fe0f138f
commit 4c22d1666e
17 changed files with 536 additions and 1088 deletions

View File

@@ -1,7 +1,7 @@
import 'package:intl/intl.dart';
extension XNumExtension on num? {
String get toFormatted {
String get separatedByComma {
final formatter = NumberFormat('#,###', 'fa_IR');
return this == null ? '':formatter.format(this);
}

View File

@@ -0,0 +1,27 @@
import 'package:flutter/services.dart';
import 'package:intl/intl.dart';
class SeparatorInputFormatter extends TextInputFormatter {
final NumberFormat _formatter;
SeparatorInputFormatter() : _formatter = NumberFormat('#,###');
@override
TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
if (newValue.text.isEmpty) {
return newValue;
}
String tmpText = newValue.text;
String cleanedText = tmpText.replaceAll(RegExp(r'\D'), '');
int? number = int.tryParse(cleanedText);
if (number == null) {
return oldValue;
}
String formattedText = _formatter.format(number);
int selectionIndex = formattedText.length;
return TextEditingValue(
text: formattedText,
selection: TextSelection.collapsed(offset: selectionIndex),
);
}
}

View File

@@ -0,0 +1,11 @@
import 'package:intl/intl.dart';
extension XString on String {
get separatedByComma {
final formatter = NumberFormat('#,###');
return formatter.format(this);
}
get clearComma{
return replaceAll(RegExp(r'\D'), '');
}
}