Reputation: 455
Can I disable input in TextField
with open keyboard?
I am trying TextField
with readOnly
property, but when I set readOnly
value true
my device keyboard hide. I want do this without hidding keyboard
Upvotes: 4
Views: 8055
Reputation: 31
As for now, you can do this by adding enabled to your TextField.
TextField(
controller: _controller,
enabled: false,
);
Upvotes: 3
Reputation: 5423
One way to do this is like so.
class _MyWidgetState extends State<MyWidget>{
var tc = TextEditingController();
var readOnlyText = 'read only';
@override
void initState() {
super.initState();
tc.text = readOnlyText;
}
@override
Widget build(BuildContext context) {
return TextField(
controller: tc,
onChanged: (_){
tc.text = readOnlyText;
tc.selection = TextSelection.fromPosition(TextPosition(offset: tc.text.length));
},
);
}
}
Upvotes: 0
Reputation: 4763
You can try this
TextField(
readyOnly: true,
showCursor: true,
// ...
),
Upvotes: 9