From 6fa8f90e8f6b8985ce5847e058e962efc1d40be5 Mon Sep 17 00:00:00 2001 From: Alan Mantoux Date: Sat, 20 Sep 2025 10:57:25 +0200 Subject: [PATCH 1/2] Adapt scroll assertions to case where `scrollable=false` --- packages/fleather/lib/src/widgets/editor.dart | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/fleather/lib/src/widgets/editor.dart b/packages/fleather/lib/src/widgets/editor.dart index 7ce54701..77dd8d93 100644 --- a/packages/fleather/lib/src/widgets/editor.dart +++ b/packages/fleather/lib/src/widgets/editor.dart @@ -1627,20 +1627,22 @@ class RawEditorState extends EditorState bool _showCaretOnScreenScheduled = false; void _showCaretOnScreen([bool withAnimation = true]) { - assert( - widget.enableInteractiveSelection - ? _scrollController.positions.isNotEmpty - : true, - 'ScrollController not attached to any scroll views. ' - 'When editor configured with scrollable = false and ' - 'enableInteractiveSelection = true, make sure the editor is the child ' - 'of a Scrollable widget.'); - assert( - widget.showCursor ? _scrollController.positions.isNotEmpty : true, - 'ScrollController not attached to any scroll views. ' - 'When editor configured with scrollable = false and ' - 'showCursor = true, make sure the editor is the child ' - 'of a Scrollable widget.'); + if (!widget.scrollable) { + assert( + widget.enableInteractiveSelection + ? Scrollable.maybeOf(context) != null + : true, + 'No Scrollable widget ancestor could be found. ' + 'When editor configured with scrollable = false and ' + 'enableInteractiveSelection = true, make sure the editor is the child ' + 'of a Scrollable widget.'); + assert( + widget.showCursor ? Scrollable.maybeOf(context) != null : true, + 'No Scrollable widget ancestor could be found. ' + 'When editor configured with scrollable = false and ' + 'showCursor = true, make sure the editor is the child ' + 'of a Scrollable widget.'); + } if (!widget.showCursor || !widget.enableInteractiveSelection || From 147f4d2cf65a59eab4f3cc609136b95569b30562 Mon Sep 17 00:00:00 2001 From: Alan Mantoux Date: Sat, 20 Sep 2025 11:18:36 +0200 Subject: [PATCH 2/2] Remove unnecessary assertions --- packages/fleather/lib/src/widgets/editor.dart | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/packages/fleather/lib/src/widgets/editor.dart b/packages/fleather/lib/src/widgets/editor.dart index 77dd8d93..ad01dd0a 100644 --- a/packages/fleather/lib/src/widgets/editor.dart +++ b/packages/fleather/lib/src/widgets/editor.dart @@ -1627,23 +1627,6 @@ class RawEditorState extends EditorState bool _showCaretOnScreenScheduled = false; void _showCaretOnScreen([bool withAnimation = true]) { - if (!widget.scrollable) { - assert( - widget.enableInteractiveSelection - ? Scrollable.maybeOf(context) != null - : true, - 'No Scrollable widget ancestor could be found. ' - 'When editor configured with scrollable = false and ' - 'enableInteractiveSelection = true, make sure the editor is the child ' - 'of a Scrollable widget.'); - assert( - widget.showCursor ? Scrollable.maybeOf(context) != null : true, - 'No Scrollable widget ancestor could be found. ' - 'When editor configured with scrollable = false and ' - 'showCursor = true, make sure the editor is the child ' - 'of a Scrollable widget.'); - } - if (!widget.showCursor || !widget.enableInteractiveSelection || _showCaretOnScreenScheduled) {