formatEditUpdate method

  1. @override
TextEditingValue formatEditUpdate(
  1. TextEditingValue oldValue,
  2. TextEditingValue newValue
)
override

Formats the text edit update by capitalizing the first character.

Parameters:

  • oldValue: The previous text editing value
  • newValue: The new text editing value after user input

Returns a TextEditingValue with the first character capitalized.

If the new text is empty, returns the new value unchanged.

Implementation

@override
TextEditingValue formatEditUpdate(
    TextEditingValue oldValue, TextEditingValue newValue) {
  if (newValue.text.isEmpty) {
    return newValue;
  }

  String text = newValue.text;
  String capitalizedText = text[0].toUpperCase() + text.substring(1);

  return newValue.copyWith(
    text: capitalizedText,
    selection: newValue.selection,
  );
}