Flutter: How to add suggestion text on keyboard?

59 Views Asked by At

I want to add a custom word on keyboard as suggestion. The logic is to show a list of suggestion words for some TextFormFields

TextFormField(
 controller: controller,
 textInputAction: TextInputAction.next,
 inputFormatters: <TextInputFormatter>[FilteringTextInputFormatter.digitsOnly],
 onTapOutside: (_) => FocusScope.of(context).unfocus(),
 decoration: InputDecoration(hintText: hintText),
 onChanged: onChanged,
)

enter image description here

1

There are 1 best solutions below

0
Jaimin Raval On

Use AutofillHints for suggesting hints on keyboard.

Example :

 TextFormField(
            controller: controller,
            autofillHints: const [AutofillHints.name], // use this line
            ...
          )