Whenever the page opens, I want the cursor to appear, but I don't want a keyboard. Does anyone know how I can do it?
TextField(
textCapitalization:TextCapitalization.sentences,
controller: _textEditingController,
autofocus: true
)
Whenever the page opens, I want the cursor to appear, but I don't want a keyboard. Does anyone know how I can do it?
TextField(
textCapitalization:TextCapitalization.sentences,
controller: _textEditingController,
autofocus: true
)
You can use SystemChannels to get access to the channel that exposes a system text input control. Call TextInput.hide method on it to hide a keyboard once the TextField is built.
A straightforward example of doing this is:
Widget build(BuildContext context) {
Future.delayed(const Duration(), () => SystemChannels.textInput.invokeMethod('TextInput.hide'));
return Scaffold(
body: TextField(
autofocus: true,
),
);
}
This may help if you don't like an idea of using Future here:
Flutter: Run method on Widget build complete