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 bool hasFocus,
required this.selection,
required this.scrollable,
required LayerLink startHandleLayerLink,
required LayerLink endHandleLayerLink,
required EdgeInsetsGeometry padding,
@ -750,6 +751,7 @@ class RenderEditor extends RenderEditableContainerBox
final CursorCont _cursorController;
final bool floatingCursorDisabled;
final bool scrollable;
Document document;
TextSelection selection;
@ -1125,17 +1127,18 @@ class RenderEditor extends RenderEditableContainerBox
@override
void performLayout() {
assert(() {
if (!constraints.hasBoundedHeight) return true;
if (!scrollable || !constraints.hasBoundedHeight) return true;
throw FlutterError.fromParts(<DiagnosticsNode>[
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'
' resize its children, so it must be '
'placed in a parent that does not constrain the main '
'axis.'),
ErrorHint(
'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(() {

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

Loading…
Cancel
Save