diff --git a/packages/flutter/lib/src/material/input.dart b/packages/flutter/lib/src/material/input.dart index e26a2dec61d..c0cf1beef8f 100644 --- a/packages/flutter/lib/src/material/input.dart +++ b/packages/flutter/lib/src/material/input.dart @@ -109,6 +109,7 @@ class _InputState extends State { _editableString.selection.end); } else if (!focused && _keyboardHandle.attached) { _keyboardHandle.release(); + _editableString.composing = TextRange.empty; } } diff --git a/packages/flutter/lib/src/widgets/editable.dart b/packages/flutter/lib/src/widgets/editable.dart index 6debfe0904b..945613f0395 100644 --- a/packages/flutter/lib/src/widgets/editable.dart +++ b/packages/flutter/lib/src/widgets/editable.dart @@ -26,10 +26,12 @@ class TextRange { end = position; /// A text range that contains nothing and is not in the text. - const TextRange.empty() + const TextRange._empty() : start = -1, end = -1; + static const TextRange empty = const TextRange._empty(); + /// The index of the first character in the range. final int start; @@ -56,7 +58,7 @@ class EditableString implements KeyboardClient { String text; // The range of text that is still being composed. - TextRange composing = const TextRange.empty(); + TextRange composing = TextRange.empty; /// The range of text that is currently selected. TextRange selection; @@ -124,7 +126,7 @@ class EditableString implements KeyboardClient { // TODO(abarth): Why is |newCursorPosition| always 1? TextRange committedRange = _replaceOrAppend(composing, text); selection = new TextRange.collapsed(committedRange.end); - composing = const TextRange.empty(); + composing = TextRange.empty; onUpdated(); } @@ -161,7 +163,7 @@ class EditableString implements KeyboardClient { } void submit(SubmitAction action) { - composing = const TextRange.empty(); + composing = TextRange.empty; onSubmitted(); } }