pub enum TextInputAction {
Show 13 variants
None,
Unspecified,
Done,
Go,
Search,
Send,
Next,
Previous,
ContinueAction,
Join,
Route,
EmergencyCall,
Newline,
}Expand description
An action the user has requested the text input control to perform.
Each action represents a logical meaning, and also configures the soft keyboard to display a certain kind of action button. The visual appearance of the action button might differ between versions of the same OS.
Despite the logical meaning of each action, choosing a particular
TextInputAction does not necessarily cause any specific behavior to
happen, other than changing the focus when appropriate. It is up to the
developer to ensure that the behavior that occurs when an action button is
pressed is appropriate for the action button chosen.
For example: If the user presses the keyboard action button on iOS when it reads “Emergency Call”, the result should not be a focus change to the next TextField. This behavior is not logically appropriate for a button that says “Emergency Call”.
See EditableText for more information about customizing action button
behavior.
Most TextInputActions are supported equally by both Android and iOS.
However, there is not a complete, direct mapping between Android’s IME input
types and iOS’s keyboard return types. Therefore, some TextInputActions
are inappropriate for one of the platforms. If a developer chooses an
inappropriate TextInputAction when running in debug mode, an error will be
thrown. If the same thing is done in release mode, then instead of sending
the inappropriate value, Android will use “unspecified” on the platform
side and iOS will use “default” on the platform side.
See also:
TextInput, which configures the platform’s keyboard setup.EditableText, which invokes callbacks when the action button is pressed.
Variants§
None
Logical meaning: There is no relevant input action for the current input
source, e.g., TextField.
Android: Corresponds to Android’s “IME_ACTION_NONE”. The keyboard setup is decided by the OS. The keyboard will likely show a return key.
iOS: iOS does not have a keyboard return type of “none.” It is
inappropriate to choose this TextInputAction when running on iOS.
Unspecified
Logical meaning: Let the OS decide which action is most appropriate.
Android: Corresponds to Android’s “IME_ACTION_UNSPECIFIED”. The OS chooses which keyboard action to display. The decision will likely be a done button or a return key.
iOS: Corresponds to iOS’s “UIReturnKeyDefault”. The title displayed in the action button is “return”.
Done
Logical meaning: The user is done providing input to a group of inputs (like a form). Some kind of finalization behavior should now take place.
Android: Corresponds to Android’s “IME_ACTION_DONE”. The OS displays a button that represents completion, e.g., a checkmark button.
iOS: Corresponds to iOS’s “UIReturnKeyDone”. The title displayed in the action button is “Done”.
Go
Logical meaning: The user has entered some text that represents a destination, e.g., a restaurant name. The “go” button is intended to take the user to a part of the app that corresponds to this destination.
Android: Corresponds to Android’s “IME_ACTION_GO”. The OS displays a button that represents taking “the user to the target of the text they typed”, e.g., a right-facing arrow button.
iOS: Corresponds to iOS’s “UIReturnKeyGo”. The title displayed in the action button is “Go”.
Search
Logical meaning: Execute a search query.
Android: Corresponds to Android’s “IME_ACTION_SEARCH”. The OS displays a button that represents a search, e.g., a magnifying glass button.
iOS: Corresponds to iOS’s “UIReturnKeySearch”. The title displayed in the action button is “Search”.
Send
Logical meaning: Sends something that the user has composed, e.g., an email or a text message.
Android: Corresponds to Android’s “IME_ACTION_SEND”. The OS displays a button that represents sending something, e.g., a paper plane button.
iOS: Corresponds to iOS’s “UIReturnKeySend”. The title displayed in the action button is “Send”.
Next
Logical meaning: The user is done with the current input source and wants to move to the next one.
Moves the focus to the next focusable item in the same FocusScope.
Android: Corresponds to Android’s “IME_ACTION_NEXT”. The OS displays a button that represents moving forward, e.g., a right-facing arrow button.
iOS: Corresponds to iOS’s “UIReturnKeyNext”. The title displayed in the action button is “Next”.
Previous
Logical meaning: The user wishes to return to the previous input source
in the group, e.g., a form with multiple TextFields.
Moves the focus to the previous focusable item in the same FocusScope.
Android: Corresponds to Android’s “IME_ACTION_PREVIOUS”. The OS displays a button that represents moving backward, e.g., a left-facing arrow button.
iOS: iOS does not have a keyboard return type of “previous.” It is
inappropriate to choose this TextInputAction when running on iOS.
ContinueAction
Logical meaning: In iOS apps, it is common for a “Back” button and “Continue” button to appear at the top of the screen. However, when the keyboard is open, these buttons are often hidden off-screen. Therefore, the purpose of the “Continue” return key on iOS is to make the “Continue” button available when the user is entering text.
Historical context aside, ContinueAction can be used any
time that the term “Continue” seems most appropriate for the given action.
Android: Android does not have an IME input type of “continue.” It is
inappropriate to choose this TextInputAction when running on Android.
iOS: Corresponds to iOS’s “UIReturnKeyContinue”. The title displayed in the action button is “Continue”. This action is only available on iOS 9.0+.
The reason that this value has “Action” post-fixed to it is because “continue” is a reserved word in Dart, as well as many other languages.
Join
Logical meaning: The user wants to join something, e.g., a wireless network.
Android: Android does not have an IME input type of “join.” It is
inappropriate to choose this TextInputAction when running on Android.
iOS: Corresponds to iOS’s “UIReturnKeyJoin”. The title displayed in the action button is “Join”.
Route
Logical meaning: The user wants routing options, e.g., driving directions.
Android: Android does not have an IME input type of “route.” It is
inappropriate to choose this TextInputAction when running on Android.
iOS: Corresponds to iOS’s “UIReturnKeyRoute”. The title displayed in the action button is “Route”.
EmergencyCall
Logical meaning: Initiate a call to emergency services.
Android: Android does not have an IME input type of “emergencyCall.” It is
inappropriate to choose this TextInputAction when running on Android.
iOS: Corresponds to iOS’s “UIReturnKeyEmergencyCall”. The title displayed in the action button is “Emergency Call”.
Newline
Logical meaning: Insert a newline character in the focused text input,
e.g., TextField.
Android: Corresponds to Android’s “IME_ACTION_NONE”. The OS displays a button that represents a new line, e.g., a carriage return button.
iOS: Corresponds to iOS’s “UIReturnKeyDefault”. The title displayed in the action button is “return”.
The term Newline exists in Flutter but not in Android
or iOS. The reason for introducing this term is so that developers can
achieve the common result of inserting new lines without needing to
understand the various IME actions on Android and return keys on iOS.
Thus, Newline is a convenience term that alleviates the
need to understand the underlying platforms to achieve this common behavior.
Trait Implementations§
Source§impl Clone for TextInputAction
impl Clone for TextInputAction
impl Copy for TextInputAction
Source§impl Debug for TextInputAction
impl Debug for TextInputAction
impl Eq for TextInputAction
Source§impl Hash for TextInputAction
impl Hash for TextInputAction
Source§impl PartialEq for TextInputAction
impl PartialEq for TextInputAction
impl StructuralPartialEq for TextInputAction
Auto Trait Implementations§
impl Freeze for TextInputAction
impl RefUnwindSafe for TextInputAction
impl Send for TextInputAction
impl Sync for TextInputAction
impl Unpin for TextInputAction
impl UnsafeUnpin for TextInputAction
impl UnwindSafe for TextInputAction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.