diff --git a/packages/flutter/lib/src/widgets/editable_text.dart b/packages/flutter/lib/src/widgets/editable_text.dart index deb47718ea..6832e39c9b 100644 --- a/packages/flutter/lib/src/widgets/editable_text.dart +++ b/packages/flutter/lib/src/widgets/editable_text.dart @@ -37,6 +37,7 @@ import 'scroll_position.dart'; import 'scrollable.dart'; import 'scrollable_helpers.dart'; import 'shortcuts.dart'; +import 'size_changed_layout_notifier.dart'; import 'spell_check.dart'; import 'tap_region.dart'; import 'text.dart'; @@ -4951,48 +4952,50 @@ class EditableTextState extends State with AutomaticKeepAliveClien _openInputConnection(); _updateSelectionRects(force: true); }, - child: _Editable( - key: _editableKey, - startHandleLayerLink: _startHandleLayerLink, - endHandleLayerLink: _endHandleLayerLink, - inlineSpan: buildTextSpan(), - value: _value, - cursorColor: _cursorColor, - backgroundCursorColor: widget.backgroundCursorColor, - showCursor: _cursorVisibilityNotifier, - forceLine: widget.forceLine, - readOnly: widget.readOnly, - hasFocus: _hasFocus, - maxLines: widget.maxLines, - minLines: widget.minLines, - expands: widget.expands, - strutStyle: widget.strutStyle, - selectionColor: _selectionOverlay?.spellCheckToolbarIsVisible ?? false - ? _spellCheckConfiguration.misspelledSelectionColor ?? widget.selectionColor - : widget.selectionColor, - textScaler: effectiveTextScaler, - textAlign: widget.textAlign, - textDirection: _textDirection, - locale: widget.locale, - textHeightBehavior: widget.textHeightBehavior ?? DefaultTextHeightBehavior.maybeOf(context), - textWidthBasis: widget.textWidthBasis, - obscuringCharacter: widget.obscuringCharacter, - obscureText: widget.obscureText, - offset: offset, - rendererIgnoresPointer: widget.rendererIgnoresPointer, - cursorWidth: widget.cursorWidth, - cursorHeight: widget.cursorHeight, - cursorRadius: widget.cursorRadius, - cursorOffset: widget.cursorOffset ?? Offset.zero, - selectionHeightStyle: widget.selectionHeightStyle, - selectionWidthStyle: widget.selectionWidthStyle, - paintCursorAboveText: widget.paintCursorAboveText, - enableInteractiveSelection: widget._userSelectionEnabled, - textSelectionDelegate: this, - devicePixelRatio: _devicePixelRatio, - promptRectRange: _currentPromptRectRange, - promptRectColor: widget.autocorrectionTextRectColor, - clipBehavior: widget.clipBehavior, + child: SizeChangedLayoutNotifier( + child: _Editable( + key: _editableKey, + startHandleLayerLink: _startHandleLayerLink, + endHandleLayerLink: _endHandleLayerLink, + inlineSpan: buildTextSpan(), + value: _value, + cursorColor: _cursorColor, + backgroundCursorColor: widget.backgroundCursorColor, + showCursor: _cursorVisibilityNotifier, + forceLine: widget.forceLine, + readOnly: widget.readOnly, + hasFocus: _hasFocus, + maxLines: widget.maxLines, + minLines: widget.minLines, + expands: widget.expands, + strutStyle: widget.strutStyle, + selectionColor: _selectionOverlay?.spellCheckToolbarIsVisible ?? false + ? _spellCheckConfiguration.misspelledSelectionColor ?? widget.selectionColor + : widget.selectionColor, + textScaler: effectiveTextScaler, + textAlign: widget.textAlign, + textDirection: _textDirection, + locale: widget.locale, + textHeightBehavior: widget.textHeightBehavior ?? DefaultTextHeightBehavior.maybeOf(context), + textWidthBasis: widget.textWidthBasis, + obscuringCharacter: widget.obscuringCharacter, + obscureText: widget.obscureText, + offset: offset, + rendererIgnoresPointer: widget.rendererIgnoresPointer, + cursorWidth: widget.cursorWidth, + cursorHeight: widget.cursorHeight, + cursorRadius: widget.cursorRadius, + cursorOffset: widget.cursorOffset ?? Offset.zero, + selectionHeightStyle: widget.selectionHeightStyle, + selectionWidthStyle: widget.selectionWidthStyle, + paintCursorAboveText: widget.paintCursorAboveText, + enableInteractiveSelection: widget._userSelectionEnabled, + textSelectionDelegate: this, + devicePixelRatio: _devicePixelRatio, + promptRectRange: _currentPromptRectRange, + promptRectColor: widget.autocorrectionTextRectColor, + clipBehavior: widget.clipBehavior, + ), ), ), ), diff --git a/packages/flutter/test/widgets/editable_text_test.dart b/packages/flutter/test/widgets/editable_text_test.dart index d259253c2d..bee6fb277d 100644 --- a/packages/flutter/test/widgets/editable_text_test.dart +++ b/packages/flutter/test/widgets/editable_text_test.dart @@ -16731,6 +16731,34 @@ void main() { final EditableTextState state = tester.state(find.byType(EditableText)); expect(state.renderEditable.cursorColor, cursorColor.withOpacity(opacity)); }); + + testWidgets('should notify on size change', (WidgetTester tester) async { + int notifyCount = 0; + await tester.pumpWidget(MaterialApp( + home: Scaffold( + body: NotificationListener( + onNotification: (SizeChangedLayoutNotification notification) { + notifyCount += 1; + return false; + }, + child: EditableText( + backgroundCursorColor: Colors.grey, + cursorColor: Colors.grey, + controller: controller, + focusNode: focusNode, + maxLines: 3, + minLines: 1, + style: textStyle, + ), + ), + ), + )); + + expect(notifyCount, equals(0)); + await tester.enterText(find.byType(EditableText), '\n'); + await tester.pumpAndSettle(); + expect(notifyCount, equals(1)); + }); } class UnsettableController extends TextEditingController {