feat: add step 5 page and update active stepper logic in poultry farm inspection

doc: some utils in core
This commit is contained in:
2025-11-22 14:12:37 +03:30
parent 6be57e058c
commit 25980c85a1

View File

@@ -0,0 +1,33 @@
import 'package:flutter/services.dart';
import 'package:intl/intl.dart';
/// A text input formatter that formats numbers with a separator.
/// Example:
/// ```dart
/// SeparatorInputFormatter()
/// ```
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),
);
}
}