I'm creating a "barcoder" text field on flutter. After the page opened which is the barcoder belong,
I need to autofocus on TextField. But on the first opening, I want to hide the keyboard. And then if the user focuses on TextField The keyboard can appear.
How can I achieve this? I already try
class FirstDisabledFocusNode extends FocusNode {
@override
bool consumeKeyboardToken() {
return false;
}
}
and it didn't work.
Here is my code
Card(
elevation: 1,
child: TextField(
autofocus: true,
focusNode: textFieldFocusNode,
onEditingComplete: () {
print('Barcode: ${textController.text}');
buttonFocusNode.requestFocus();
events!(context);
if (textController.text.isNotEmpty) {
_audioCache.play('success.mp3');
}
},
controller: textController,
decoration: const InputDecoration(
fillColor: Colors.white,
prefixIcon: Icon(Icons.qr_code),
hintText: 'Barcode',
focusColor: Palette.asBlue,
border: InputBorder.none,
focusedBorder: InputBorder.none),
),
);