How to disable predictive text in TextField of Flutter?
Asked Answered
S

5

40

I want to disable predictive text which comes in the keyboard of a textfield. It is not so difficult in native android and IOS but I have not found a solution in a Flutter.

I have tried using autocorrect: false and changing keyboardtypes but it is not working.

TextField(
          autocorrect: false,
          keyboardType: TextInputType.emailAddress,
          decoration: new InputDecoration(hintText: "Enter text"),
          autofocus: true,
        ),
Silvio answered 14/3, 2019 at 7:44 Comment(0)
P
46

If neither enableSuggestions nor autocorrect can solve the problem, try setting keyboardType to TextInputType.visiblePassword.

Peri answered 1/5, 2020 at 5:28 Comment(2)
TextInputType.visiblePassword works but I need multiline button in keyboardAerator
enableSuggestions: false worked for me. Thanks.Horme
S
25

You can try to add enableSuggestions = false to your textfield widget. This should disable the predictive text from your keyboard as supposed to https://github.com/flutter/flutter/pull/42550.

TextField(
      autocorrect: false,
      enableSuggestions: false,
      keyboardType: TextInputType.emailAddress,
      decoration: new InputDecoration(hintText: "Enter text"),
      autofocus: true,
    ),
Scarce answered 28/1, 2020 at 19:33 Comment(0)
E
4

At the time of writing this answer, this is not yet available in Android. But using autocorrect: false on iOS should work fine.

Check: https://github.com/flutter/flutter/issues/22828

Eruption answered 14/3, 2019 at 12:3 Comment(0)
M
4

This worked for me on both iOS and android

                    TextField(
                        autocorrect: false,
                        obscureText: true,
                        controller: answerText,
                        textAlign: TextAlign.center,
                        keyboardType: TextInputType.text,
                        textInputAction: TextInputAction.done,
                        autofocus: true,
                        onChanged: (value) {
                          setState(() {
                            result = value;
                          });
                        },),

The only downside is that it obscure from the screen what is written. A workaround is to add somewhere in the screen Text(result)

Multiparous answered 5/11, 2019 at 22:58 Comment(0)
S
-1

i tried this and it's solved

TextField(
  ...
  enableSuggestions: false,
  enableIMEPersonalizedLearning: false,
  ...
),
Savoie answered 11/5 at 20:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.