@@ -10,12 +10,32 @@ typedef EmbedBuilder = Widget Function(
10
10
11
11
typedef CustomStyleBuilder = TextStyle Function (Attribute attribute);
12
12
13
+ /// Delegate interface for the [EditorTextSelectionGestureDetectorBuilder] .
14
+ ///
15
+ /// The interface is usually implemented by textfield implementations wrapping
16
+ /// [EditableText] , that use a [EditorTextSelectionGestureDetectorBuilder]
17
+ /// to build a [EditorTextSelectionGestureDetector] for their [EditableText] .
18
+ /// The delegate provides the builder with information about the current state
19
+ /// of the textfield.
20
+ /// Based on these information, the builder adds the correct gesture handlers
21
+ /// to the gesture detector.
22
+ ///
23
+ /// See also:
24
+ ///
25
+ /// * [TextField] , which implements this delegate for the Material textfield.
26
+ /// * [CupertinoTextField] , which implements this delegate for the Cupertino
27
+ /// textfield.
13
28
abstract class EditorTextSelectionGestureDetectorBuilderDelegate {
14
- GlobalKey <EditorState > getEditableTextKey ();
29
+ /// [GlobalKey] to the [EditableText] for which the
30
+ /// [EditorTextSelectionGestureDetectorBuilder] will build
31
+ /// a [EditorTextSelectionGestureDetector] .
32
+ GlobalKey <EditorState > get editableTextKey;
15
33
16
- bool getForcePressEnabled ();
34
+ /// Whether the textfield should respond to force presses.
35
+ bool get forcePressEnabled;
17
36
18
- bool getSelectionEnabled ();
37
+ /// Whether the user may select text in the textfield.
38
+ bool get selectionEnabled;
19
39
}
20
40
21
41
/// Builds a [EditorTextSelectionGestureDetector] to wrap an [EditableText] .
@@ -60,7 +80,7 @@ class EditorTextSelectionGestureDetectorBuilder {
60
80
/// The [State] of the [EditableText] for which the builder will provide a
61
81
/// [EditorTextSelectionGestureDetector] .
62
82
@protected
63
- EditorState ? get editor => delegate.getEditableTextKey () .currentState;
83
+ EditorState ? get editor => delegate.editableTextKey .currentState;
64
84
65
85
/// The [RenderObject] of the [EditableText] for which the builder will
66
86
/// provide a [EditorTextSelectionGestureDetector] .
@@ -103,9 +123,9 @@ class EditorTextSelectionGestureDetectorBuilder {
103
123
/// which triggers this callback.
104
124
@protected
105
125
void onForcePressStart (ForcePressDetails details) {
106
- assert (delegate.getForcePressEnabled () );
126
+ assert (delegate.forcePressEnabled );
107
127
shouldShowSelectionToolbar = true ;
108
- if (delegate.getSelectionEnabled () ) {
128
+ if (delegate.selectionEnabled ) {
109
129
renderEditor! .selectWordsInRange (
110
130
details.globalPosition,
111
131
null ,
@@ -127,7 +147,7 @@ class EditorTextSelectionGestureDetectorBuilder {
127
147
/// which triggers this callback.
128
148
@protected
129
149
void onForcePressEnd (ForcePressDetails details) {
130
- assert (delegate.getForcePressEnabled () );
150
+ assert (delegate.forcePressEnabled );
131
151
renderEditor! .selectWordsInRange (
132
152
details.globalPosition,
133
153
null ,
@@ -148,7 +168,7 @@ class EditorTextSelectionGestureDetectorBuilder {
148
168
/// this callback.
149
169
@protected
150
170
void onSingleTapUp (TapUpDetails details) {
151
- if (delegate.getSelectionEnabled () ) {
171
+ if (delegate.selectionEnabled ) {
152
172
renderEditor! .selectWordEdge (SelectionChangedCause .tap);
153
173
}
154
174
}
@@ -177,7 +197,7 @@ class EditorTextSelectionGestureDetectorBuilder {
177
197
/// which triggers this callback.
178
198
@protected
179
199
void onSingleLongTapStart (LongPressStartDetails details) {
180
- if (delegate.getSelectionEnabled () ) {
200
+ if (delegate.selectionEnabled ) {
181
201
renderEditor! .selectPositionAt (
182
202
from: details.globalPosition,
183
203
cause: SelectionChangedCause .longPress,
@@ -196,7 +216,7 @@ class EditorTextSelectionGestureDetectorBuilder {
196
216
/// triggers this callback.
197
217
@protected
198
218
void onSingleLongTapMoveUpdate (LongPressMoveUpdateDetails details) {
199
- if (delegate.getSelectionEnabled () ) {
219
+ if (delegate.selectionEnabled ) {
200
220
renderEditor! .selectPositionAt (
201
221
from: details.globalPosition,
202
222
cause: SelectionChangedCause .longPress,
@@ -230,7 +250,7 @@ class EditorTextSelectionGestureDetectorBuilder {
230
250
/// which triggers this callback.
231
251
@protected
232
252
void onDoubleTapDown (TapDownDetails details) {
233
- if (delegate.getSelectionEnabled () ) {
253
+ if (delegate.selectionEnabled ) {
234
254
renderEditor! .selectWord (SelectionChangedCause .tap);
235
255
if (shouldShowSelectionToolbar) {
236
256
editor! .showToolbar ();
@@ -289,9 +309,8 @@ class EditorTextSelectionGestureDetectorBuilder {
289
309
return EditorTextSelectionGestureDetector (
290
310
key: key,
291
311
onTapDown: onTapDown,
292
- onForcePressStart:
293
- delegate.getForcePressEnabled () ? onForcePressStart : null ,
294
- onForcePressEnd: delegate.getForcePressEnabled () ? onForcePressEnd : null ,
312
+ onForcePressStart: delegate.forcePressEnabled ? onForcePressStart : null ,
313
+ onForcePressEnd: delegate.forcePressEnabled ? onForcePressEnd : null ,
295
314
onSingleTapUp: onSingleTapUp,
296
315
onSingleTapCancel: onSingleTapCancel,
297
316
onSingleLongTapStart: onSingleLongTapStart,
0 commit comments