@@ -687,7 +687,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
687687 final TextRange line = _textPainter.getLineBoundary (position);
688688 // If text is obscured, the entire string should be treated as one line.
689689 if (obscureText) {
690- return TextSelection (baseOffset: 0 , extentOffset: _plainText .length);
690+ return TextSelection (baseOffset: 0 , extentOffset: plainText .length);
691691 }
692692 return TextSelection (baseOffset: line.start, extentOffset: line.end);
693693 }
@@ -756,12 +756,12 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
756756
757757 void _setSelection (TextSelection nextSelection, SelectionChangedCause cause) {
758758 if (nextSelection.isValid) {
759- // The nextSelection is calculated based on _plainText , which can be out
759+ // The nextSelection is calculated based on plainText , which can be out
760760 // of sync with the textSelectionDelegate.textEditingValue by one frame.
761761 // This is due to the render editable and editable text handle pointer
762762 // event separately. If the editable text changes the text during the
763763 // event handler, the render editable will use the outdated text stored in
764- // the _plainText when handling the pointer event.
764+ // the plainText when handling the pointer event.
765765 //
766766 // If this happens, we need to make sure the new selection is still valid.
767767 final int textLength = textSelectionDelegate.textEditingValue.text.length;
@@ -803,16 +803,16 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
803803 _textLayoutLastMinWidth = null ;
804804 }
805805
806- String ? _cachedPlainText;
807- // Returns a plain text version of the text in the painter.
808- //
809- // Returns the obscured text when [obscureText] is true. See
810- // [obscureText] and [obscuringCharacter].
811- String get _plainText {
812- return _cachedPlainText ?? = _textPainter.text! .toPlainText (includeSemanticsLabels: false );
813- }
806+ /// Returns a plain text version of the text in [TextPainter] .
807+ ///
808+ /// If [obscureText] is true, returns the obscured text. See
809+ /// [obscureText] and [obscuringCharacter] .
810+ /// In order to get the styled text as an [InlineSpan] tree, use [text] .
811+ String get plainText => _textPainter.plainText;
814812
815- /// The text to display.
813+ /// The text to paint in the form of a tree of [InlineSpan] s.
814+ ///
815+ /// In order to get the plain text representation, use [plainText] .
816816 InlineSpan ? get text => _textPainter.text;
817817 final TextPainter _textPainter;
818818 AttributedString ? _cachedAttributedValue;
@@ -821,9 +821,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
821821 if (_textPainter.text == value) {
822822 return ;
823823 }
824- _cachedPlainText = null ;
825824 _cachedLineBreakCount = null ;
826-
827825 _textPainter.text = value;
828826 _cachedAttributedValue = null ;
829827 _cachedCombinedSemanticsInfos = null ;
@@ -1328,7 +1326,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
13281326 }
13291327 if (_cachedAttributedValue == null ) {
13301328 if (obscureText) {
1331- _cachedAttributedValue = AttributedString (obscuringCharacter * _plainText .length);
1329+ _cachedAttributedValue = AttributedString (obscuringCharacter * plainText .length);
13321330 } else {
13331331 final StringBuffer buffer = StringBuffer ();
13341332 int offset = 0 ;
@@ -1855,23 +1853,24 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
18551853 if (maxLines == null ) {
18561854 final double estimatedHeight;
18571855 if (width == double .infinity) {
1858- estimatedHeight = preferredLineHeight * (_countHardLineBreaks (_plainText ) + 1 );
1856+ estimatedHeight = preferredLineHeight * (_countHardLineBreaks (plainText ) + 1 );
18591857 } else {
18601858 _layoutText (maxWidth: width);
18611859 estimatedHeight = _textPainter.height;
18621860 }
18631861 return math.max (estimatedHeight, minHeight);
18641862 }
1863+
18651864 // TODO(LongCatIsLooong): this is a workaround for
1866- // https://github.com/flutter/flutter/issues/112123 .
1865+ // https://github.com/flutter/flutter/issues/112123.
18671866 // Use preferredLineHeight since SkParagraph currently returns an incorrect
18681867 // height.
18691868 final TextHeightBehavior ? textHeightBehavior = this .textHeightBehavior;
18701869 final bool usePreferredLineHeightHack = maxLines == 1
1871- && text? .codeUnitAt (0 ) == null
1872- && strutStyle != null && strutStyle != StrutStyle .disabled
1873- && textHeightBehavior != null
1874- && (! textHeightBehavior.applyHeightToFirstAscent || ! textHeightBehavior.applyHeightToLastDescent);
1870+ && text? .codeUnitAt (0 ) == null
1871+ && strutStyle != null && strutStyle != StrutStyle .disabled
1872+ && textHeightBehavior != null
1873+ && (! textHeightBehavior.applyHeightToFirstAscent || ! textHeightBehavior.applyHeightToLastDescent);
18751874
18761875 // Special case maxLines == 1 since it forces the scrollable direction
18771876 // to be horizontal. Report the real height to prevent the text from being
@@ -2142,14 +2141,14 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
21422141 TextSelection _getWordAtOffset (TextPosition position) {
21432142 debugAssertLayoutUpToDate ();
21442143 // When long-pressing past the end of the text, we want a collapsed cursor.
2145- if (position.offset >= _plainText .length) {
2144+ if (position.offset >= plainText .length) {
21462145 return TextSelection .fromPosition (
2147- TextPosition (offset: _plainText .length, affinity: TextAffinity .upstream)
2146+ TextPosition (offset: plainText .length, affinity: TextAffinity .upstream)
21482147 );
21492148 }
21502149 // If text is obscured, the entire sentence should be treated as one word.
21512150 if (obscureText) {
2152- return TextSelection (baseOffset: 0 , extentOffset: _plainText .length);
2151+ return TextSelection (baseOffset: 0 , extentOffset: plainText .length);
21532152 }
21542153 final TextRange word = _textPainter.getWordBoundary (position);
21552154 final int effectiveOffset;
@@ -2170,7 +2169,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
21702169 // If the platform is Android and the text is read only, try to select the
21712170 // previous word if there is one; otherwise, select the single whitespace at
21722171 // the position.
2173- if (TextLayoutMetrics .isWhitespace (_plainText .codeUnitAt (effectiveOffset))
2172+ if (TextLayoutMetrics .isWhitespace (plainText .codeUnitAt (effectiveOffset))
21742173 && effectiveOffset > 0 ) {
21752174 assert (defaultTargetPlatform != null );
21762175 final TextRange ? previousWord = _getPreviousWord (word.start);
0 commit comments