I want to hide my keyboard in all situations

703 Views Asked by At

I am making a barcode scanning application and I am making this application to work on handheld terminals as well. If the user presses the read key on the hand terminal, the return value will be filled into the textfield. I want to not see this and prevent the keyboard from reopening in other setState situations. How can I do that?

For clarity: I focus on the textfield and assign a value with the barcode reading key on the hand terminal, but I don't want the keyboard to appear on the screen. Is there a way I can do this?

Container(
        height: 0,
        width: 0,
        child: TextField(
          autofocus: true,
          controller: editingController,
          onChanged: (val) {
            setState(() {
              value = editingController.text;
            });
            SystemChannels.textInput.invokeMethod("TextInput.hide");
            print(editingController.text);
            editingController.clear();
            print(value + "aaa");
          },
        ),
      ),
1

There are 1 best solutions below

18
On

You need to assign a FocusNode() instance to your text field and call focusNode.unfocus() inside onChanged