@@ -7,12 +7,11 @@ import 'package:flutter/services.dart';
7
7
8
8
import 'intents.dart' ;
9
9
10
- /// An [Intent] to send the inpput event straight to the engine.
10
+ /// An [Intent] to send the input event straight to the engine.
11
11
///
12
- /// Text input widgets should typically use this [Intent] instead of
13
- /// [DoNothingIntent] , to indicate the text-input-related event that triggered
14
- /// the [Intent] should be handled by the engine instead of the Flutter
15
- /// framework.
12
+ /// This [Intent] is currently used by [DefaultTextEditingShortcuts] to indicate
13
+ /// the key events that was bound to a particular shortcut should be handled
14
+ /// by the platform's text input system, instead of the Flutter framework.
16
15
///
17
16
/// See also:
18
17
///
@@ -22,16 +21,18 @@ class DoNothingAndStopPropagationTextIntent extends Intent {
22
21
const DoNothingAndStopPropagationTextIntent ();
23
22
}
24
23
25
- /// An [Intent] that represent a command that isn't recognized by the Flutter
26
- /// framework .
24
+ /// An [Intent] representing an unrecognized text input command sent by the
25
+ /// platform's text input plugin .
27
26
///
28
27
/// {@template flutter.services.textEditingIntents.privateCommands}
29
- /// Some input method editors may define "private" commands to implement
28
+ /// Some input method editors (IMEs) may define "private" commands to implement
30
29
/// domain-specific features that are only known between certain input methods
31
30
/// and their clients.
32
31
///
33
- /// For instance, on Android there is `InputConnection.performPrivateCommand` ,
34
- /// and on macOS there is `-[NSTextInputClient doCommandBySelector:]` .
32
+ /// For instance, on Android, the IME can send app-private commands via
33
+ /// [`InputConnection.performPrivateCommand`] (https://developer.android.com/reference/android/view/inputmethod/InputConnection#performPrivateCommand(java.lang.String,%20android.os.Bundle)),
34
+ /// and on macOS input fields receives "dynamic" commands in the form of selectors:
35
+ /// [`-[NSTextInputClient doCommandBySelector:] `](https://developer.apple.com/documentation/appkit/nstextinputclient/1438256-docommand).
35
36
/// {@endtemplate}
36
37
class PerformPrivateTextInputCommandIntent extends Intent {
37
38
/// Creates a [PerformPrivateTextInputCommandIntent] , using the unrecognized
@@ -268,41 +269,104 @@ class UpdateSelectionIntent extends Intent {
268
269
final SelectionChangedCause cause;
269
270
}
270
271
272
+ /// An [Intent] that represents an autofill attempt made by the system's
273
+ /// autofill service.
274
+ ///
275
+ /// On platforms where autofill is not distinguishable from regular user input,
276
+ /// autofill may be interpreted as a [UpdateTextEditingValueIntent] instead
277
+ /// of a [PerformAutofillIntent] .
271
278
class PerformAutofillIntent extends Intent {
279
+ /// Creates a [PerformAutofillIntent] .
272
280
const PerformAutofillIntent (this .autofillValue);
273
281
282
+ /// The [TextEditingValue] s to be autofilled.
283
+ ///
284
+ /// The map is keyed by [AutofillClient.autofillId] which is the unique
285
+ /// identifier of an autofill-enabled text input field.
274
286
final Map <String , TextEditingValue > autofillValue;
275
287
}
276
288
289
+ /// An [Intent] that represents a [TextInputAction] .
277
290
class PerformIMEActionIntent extends Intent {
291
+ /// Creates a [PerformIMEActionIntent] .
278
292
const PerformIMEActionIntent (this .textInputAction);
279
293
294
+ /// The [TextInputAction] to be performed.
280
295
final TextInputAction textInputAction;
281
296
}
282
297
298
+ /// An [Intent] that represents a user action that replaces the content of an
299
+ /// editable text field with a different [TextEditingValue] .
300
+ ///
301
+ /// One example of such user actions is autofill, where the existing text in
302
+ /// the text field gets erased and replaced with the autofilled value. For
303
+ /// granular changes made to the text field, such as text deletion and text
304
+ /// insertion, use [UpdateTextEditingValueWtihDeltasIntent] if possible.
305
+ ///
306
+ /// See also:
307
+ ///
308
+ /// * [UpdateTextEditingValueWtihDeltasIntent] , which makes partial updates
309
+ /// to the content of an editable text field.
283
310
class UpdateTextEditingValueIntent extends Intent {
284
- UpdateTextEditingValueIntent (this .newValue, {
311
+ /// Creates a [UpdateTextEditingValueIntent] .
312
+ const UpdateTextEditingValueIntent (this .newValue, {
285
313
this .cause = SelectionChangedCause .keyboard,
286
314
});
287
315
316
+ /// The new [TextEditingValue] of the target text field.
288
317
final TextEditingValue newValue;
318
+
319
+ /// {@macro flutter.widgets.TextEditingIntents.cause}
289
320
final SelectionChangedCause cause;
290
321
}
291
322
323
+ /// An [Intent] that represents a user action, a sequence of user actions that
324
+ /// cause granular changes to be made to the current [TextEditingValue] of an
325
+ /// editable text field.
326
+ ///
327
+ /// This [Intent] should typically be used over [UpdateTextEditingValueIntent]
328
+ /// if the user action does not completely replaces the contexts of the text
329
+ /// field in one go, such as inserting text at the caret location.
330
+ ///
331
+ /// See also:
332
+ /// * [UpdateTextEditingValueIntent] which represents a single action that
333
+ /// replaces the entire text field with a new [TextEditingValue].
292
334
class UpdateTextEditingValueWtihDeltasIntent extends Intent {
293
- UpdateTextEditingValueWtihDeltasIntent (this . deltas, {
335
+ /// Creates an [UpdateTextEditingValueWtihDeltasIntent] .
336
+ const UpdateTextEditingValueWtihDeltasIntent (this . deltas, {
294
337
this .cause = SelectionChangedCause .keyboard
295
338
});
296
339
340
+ /// The [TextEditingDelta] sequence that represents the user initiated text
341
+ /// changes.
297
342
final Iterable <TextEditingDelta > deltas;
343
+
344
+ /// {@macro flutter.widgets.TextEditingIntents.cause}
298
345
final SelectionChangedCause cause;
299
346
}
300
347
348
+ /// An [Intent] that represents the state of the [TextInputConnection] has
349
+ /// changed on the platform's text input plugin side.
301
350
class TextInputConnectionControlIntent extends Intent {
302
351
const TextInputConnectionControlIntent ._(this ._controlCode);
303
352
final int _controlCode;
304
353
354
+ /// The platform's text input plugin has closed the current
355
+ /// [TextInputConnection] .
356
+ ///
357
+ /// The input field that initiated the [TextInputConnection] should properly
358
+ /// close the connection and finalize editing upon receiving this [Intent] .
305
359
static const TextInputConnectionControlIntent close = TextInputConnectionControlIntent ._(0 );
360
+
361
+ /// The platform's text input plugin has requested a reconnect for the current
362
+ /// [TextInputConnection] .
363
+ ///
364
+ /// The platform's text input plugin sends this command when it loses its
365
+ /// state (for example when it had to restart). The input field should
366
+ /// typically call [TextInput.attachConnection] using the existing
367
+ /// [TextInputConnection] object, then call
368
+ /// [TextInputConnection.setEditingState] to send the current
369
+ /// [TextEditingValue] of the connected text field to the platform.
306
370
static const TextInputConnectionControlIntent reconnect = TextInputConnectionControlIntent ._(1 );
307
371
308
372
@override
@@ -315,13 +379,37 @@ class TextInputConnectionControlIntent extends Intent {
315
379
}
316
380
}
317
381
382
+ /// An [Intent] triggered by user actions that initiate, update or end an iOS
383
+ /// floating cursor session.
384
+ ///
385
+ /// When the user performs a two-finger pan gesture to pick up the cursor, UIKit
386
+ /// initiates a floating cursor session that allows the user to move the cursor
387
+ /// freely using the pan gesture.
388
+ ///
389
+ /// This [Intent] will be sent to the text field whenever the state of the
390
+ /// floating cursor changes. Text field implementers should provide visual
391
+ /// feedback in response to these changes, should they choose to support
392
+ /// floating cursor on iOS.
318
393
class UpdateFloatingCursorIntent extends Intent {
394
+ /// Creates a [UpdateFloatingCursorIntent] .
319
395
const UpdateFloatingCursorIntent (this .floatingCursorPoint);
396
+
397
+ /// The state of the current floating cursor session reported by the iOS text
398
+ /// input control.
320
399
final RawFloatingCursorPoint floatingCursorPoint;
321
400
}
322
401
323
- class HighlightAutocorrectTextRangeIntent extends Intent {
324
- const HighlightAutocorrectTextRangeIntent (this .highlightRange);
402
+ /// An [Intent] triggers when iOS detects misspelled words or text replacement
403
+ /// candidates in recently typed text.
404
+ ///
405
+ /// See also:
406
+ ///
407
+ /// * [iOS text replacement and autocorrect] (https://support.apple.com/en-us/HT207525).
408
+ class HighlightiOSReplacementRangeIntent extends Intent {
409
+ /// Creates a [HighlightiOSReplacementRangeIntent] .
410
+ const HighlightiOSReplacementRangeIntent (this .highlightRange);
325
411
412
+ /// The range of the text in the text field needs to be highlighted to
413
+ /// indicate of the range of autocorrect.
326
414
final TextRange highlightRange;
327
415
}
0 commit comments