Fix unbounded height error when not scrollable

pull/620/head
Nicolas Dion Bouchard 3 years ago
parent 2f8c8fed36
commit a3f26f3c14
  1. 9
      lib/src/widgets/editor.dart
  2. 5
      lib/src/widgets/raw_editor.dart

@ -721,6 +721,7 @@ class RenderEditor extends RenderEditableContainerBox
required TextDirection textDirection, required TextDirection textDirection,
required bool hasFocus, required bool hasFocus,
required this.selection, required this.selection,
required this.scrollable,
required LayerLink startHandleLayerLink, required LayerLink startHandleLayerLink,
required LayerLink endHandleLayerLink, required LayerLink endHandleLayerLink,
required EdgeInsetsGeometry padding, required EdgeInsetsGeometry padding,
@ -750,6 +751,7 @@ class RenderEditor extends RenderEditableContainerBox
final CursorCont _cursorController; final CursorCont _cursorController;
final bool floatingCursorDisabled; final bool floatingCursorDisabled;
final bool scrollable;
Document document; Document document;
TextSelection selection; TextSelection selection;
@ -1125,17 +1127,18 @@ class RenderEditor extends RenderEditableContainerBox
@override @override
void performLayout() { void performLayout() {
assert(() { assert(() {
if (!constraints.hasBoundedHeight) return true; if (!scrollable || !constraints.hasBoundedHeight) return true;
throw FlutterError.fromParts(<DiagnosticsNode>[ throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary('RenderEditableContainerBox must have ' ErrorSummary('RenderEditableContainerBox must have '
'unlimited space along its main axis.'), 'unlimited space along its main axis when it is scrollable.'),
ErrorDescription('RenderEditableContainerBox does not clip or' ErrorDescription('RenderEditableContainerBox does not clip or'
' resize its children, so it must be ' ' resize its children, so it must be '
'placed in a parent that does not constrain the main ' 'placed in a parent that does not constrain the main '
'axis.'), 'axis.'),
ErrorHint( ErrorHint(
'You probably want to put the RenderEditableContainerBox inside a ' 'You probably want to put the RenderEditableContainerBox inside a '
'RenderViewport with a matching main axis.') 'RenderViewport with a matching main axis or disable the '
'scrollable property.')
]); ]);
}()); }());
assert(() { assert(() {

@ -295,6 +295,7 @@ class RawEditorState extends EditorState
document: _doc, document: _doc,
selection: widget.controller.selection, selection: widget.controller.selection,
hasFocus: _hasFocus, hasFocus: _hasFocus,
scrollable: widget.scrollable,
cursorController: _cursorCont, cursorController: _cursorCont,
textDirection: _textDirection, textDirection: _textDirection,
startHandleLayerLink: _startHandleLayerLink, startHandleLayerLink: _startHandleLayerLink,
@ -333,6 +334,7 @@ class RawEditorState extends EditorState
document: _doc, document: _doc,
selection: widget.controller.selection, selection: widget.controller.selection,
hasFocus: _hasFocus, hasFocus: _hasFocus,
scrollable: widget.scrollable,
textDirection: _textDirection, textDirection: _textDirection,
startHandleLayerLink: _startHandleLayerLink, startHandleLayerLink: _startHandleLayerLink,
endHandleLayerLink: _endHandleLayerLink, endHandleLayerLink: _endHandleLayerLink,
@ -934,6 +936,7 @@ class _Editor extends MultiChildRenderObjectWidget {
required this.document, required this.document,
required this.textDirection, required this.textDirection,
required this.hasFocus, required this.hasFocus,
required this.scrollable,
required this.selection, required this.selection,
required this.startHandleLayerLink, required this.startHandleLayerLink,
required this.endHandleLayerLink, required this.endHandleLayerLink,
@ -951,6 +954,7 @@ class _Editor extends MultiChildRenderObjectWidget {
final Document document; final Document document;
final TextDirection textDirection; final TextDirection textDirection;
final bool hasFocus; final bool hasFocus;
final bool scrollable;
final TextSelection selection; final TextSelection selection;
final LayerLink startHandleLayerLink; final LayerLink startHandleLayerLink;
final LayerLink endHandleLayerLink; final LayerLink endHandleLayerLink;
@ -969,6 +973,7 @@ class _Editor extends MultiChildRenderObjectWidget {
document: document, document: document,
textDirection: textDirection, textDirection: textDirection,
hasFocus: hasFocus, hasFocus: hasFocus,
scrollable: scrollable,
selection: selection, selection: selection,
startHandleLayerLink: startHandleLayerLink, startHandleLayerLink: startHandleLayerLink,
endHandleLayerLink: endHandleLayerLink, endHandleLayerLink: endHandleLayerLink,

Loading…
Cancel
Save