Skip to main content

TextInputAction

Enum TextInputAction 

Source
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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for TextInputAction

Source§

impl Debug for TextInputAction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for TextInputAction

Source§

impl Hash for TextInputAction

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TextInputAction

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TextInputAction

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,