diff --git a/packages/flutter/lib/src/services/text_input.dart b/packages/flutter/lib/src/services/text_input.dart index c3a8a15f8a7..bc3f66b14f5 100644 --- a/packages/flutter/lib/src/services/text_input.dart +++ b/packages/flutter/lib/src/services/text_input.dart @@ -1195,16 +1195,23 @@ abstract class DeltaTextInputClient extends TextInputClient { /// to the client's editing state. A change is any mutation to the raw text /// value, or any updates to the selection and/or composing region. /// - /// Here is an example of what implementation of this method could look like: /// {@tool snippet} + /// This example shows what an implementation of this method could look like. + /// + /// ```dart + /// TextEditingValue? _localValue; /// @override /// void updateEditingValueWithDeltas(List textEditingDeltas) { - /// TextEditingValue newValue = _previousValue; + /// if (_localValue == null) { + /// return; + /// } + /// TextEditingValue newValue = _localValue!; /// for (final TextEditingDelta delta in textEditingDeltas) { /// newValue = delta.apply(newValue); /// } /// _localValue = newValue; /// } + /// ``` /// {@end-tool} void updateEditingValueWithDeltas(List textEditingDeltas); }