fillSuggestionValue method

void fillSuggestionValue(
  1. String rawValue
)

Fills the active field with a suggestion value, automatically applying thousands formatting.

Implementation

void fillSuggestionValue(String rawValue) {
  final field = _focusedField;
  if (field == null) return;
  final controller = controllers[field];
  if (controller == null) return;

  // Apply thousands formatting if value is purely numeric
  String displayVal = rawValue;
  if (RegExp(r'^\d+$').hasMatch(rawValue)) {
    displayVal = formatThousands(rawValue);
  }

  controller.value = TextEditingValue(
    text: displayVal,
    selection: TextSelection.collapsed(offset: displayVal.length),
  );
  notifyListeners();
}