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