@@ -21,7 +21,6 @@ import 'package:super_editor/src/default_editor/list_items.dart';
21
21
import 'package:super_editor/src/default_editor/tasks.dart' ;
22
22
import 'package:super_editor/src/infrastructure/_logging.dart' ;
23
23
import 'package:super_editor/src/infrastructure/content_layers.dart' ;
24
- import 'package:super_editor/src/infrastructure/document_gestures.dart' ;
25
24
import 'package:super_editor/src/infrastructure/documents/document_scaffold.dart' ;
26
25
import 'package:super_editor/src/infrastructure/documents/document_scroller.dart' ;
27
26
import 'package:super_editor/src/infrastructure/documents/selection_leader_document_layer.dart' ;
@@ -131,7 +130,7 @@ class SuperEditor extends StatefulWidget {
131
130
this .iOSToolbarBuilder,
132
131
this .createOverlayControlsClipper,
133
132
this .plugins = const {},
134
- this .scrollOff = AxisOffset .zero ,
133
+ this .autoScrollController ,
135
134
this .debugPaint = const DebugPaintConfig (),
136
135
this .documentLayoutBuilder,
137
136
}) : stylesheet = stylesheet ?? defaultStylesheet,
@@ -141,10 +140,6 @@ class SuperEditor extends StatefulWidget {
141
140
: [...defaultComponentBuilders, const UnknownComponentBuilder ()],
142
141
super (key: key);
143
142
144
- /// How far the selection extent can be from the top and bottom before triggering auto-scroll behavior. Defaults to
145
- /// zero for both top and bottom, so scrolling will only take place if the caret would leave the viewport.
146
- final AxisOffset scrollOff;
147
-
148
143
/// [FocusNode] for the entire `SuperEditor` .
149
144
final FocusNode ? focusNode;
150
145
@@ -168,6 +163,8 @@ class SuperEditor extends StatefulWidget {
168
163
/// `Scrollable` .
169
164
final ScrollController ? scrollController;
170
165
166
+ final AutoScrollController ? autoScrollController;
167
+
171
168
/// [GlobalKey] that's bound to the [DocumentLayout] within
172
169
/// this `SuperEditor` .
173
170
///
@@ -397,9 +394,7 @@ class SuperEditorState extends State<SuperEditor> {
397
394
_composer = widget.composer;
398
395
399
396
_scrollController = widget.scrollController ?? ScrollController ();
400
- _autoScrollController = AutoScrollController (
401
- selectionExtentAutoScrollBoundary: widget.scrollOff,
402
- );
397
+ _autoScrollController = widget.autoScrollController ?? AutoScrollController ();
403
398
404
399
_docLayoutKey = widget.documentLayoutKey ?? GlobalKey ();
405
400
@@ -460,6 +455,13 @@ class SuperEditorState extends State<SuperEditor> {
460
455
_scrollController = widget.scrollController ?? ScrollController ();
461
456
}
462
457
458
+ if (widget.autoScrollController != oldWidget.autoScrollController) {
459
+ if (oldWidget.autoScrollController == null ) {
460
+ _autoScrollController.dispose ();
461
+ }
462
+ _autoScrollController = widget.autoScrollController ?? AutoScrollController ();
463
+ }
464
+
463
465
_recomputeIfLayoutShouldShowCaret ();
464
466
}
465
467
@@ -478,6 +480,10 @@ class SuperEditorState extends State<SuperEditor> {
478
480
_focusNode.dispose ();
479
481
}
480
482
483
+ if (widget.autoScrollController == null ) {
484
+ _autoScrollController.dispose ();
485
+ }
486
+
481
487
super .dispose ();
482
488
}
483
489
0 commit comments