Нажмите и не откроете клавиатуру?Если это так, просто создайте класс и присвойте ему focusNode
, установив hasFocus
в false
, например:
class AlwaysDisabledFocusNode extends FocusNode {
@override
bool get hasFocus => false;
}
new TextField(
focusNode: AlwaysDisabledFocusNode(),
onTap: () {},
keyboardType: TextInputType.text,
decoration: InputDecoration(
border: InputBorder.none,
icon: Icon(Icons.apps),
hintText: 'Password'),
style: Theme.of(context).textTheme.body1,
),
![enter image description here](https://i.stack.imgur.com/wO4mI.gif)
С readOnly: true
он меняет цвет значка при клике
new TextField(readOnly: true,
//focusNode: AlwaysDisabledFocusNode(),
onTap: () {},
keyboardType: TextInputType.text,
decoration: InputDecoration(
border: InputBorder.none,
icon: Icon(Icons.apps),
hintText: 'Password'),
style: Theme.of(context).textTheme.body1,
),
![enter image description here](https://i.stack.imgur.com/kPUOk.gif)
Я думаю, тогда вам нужно поставить Row
с TextField
и IconButton
, с отдельными действиями.
new Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Expanded(
child: Padding(
child: new TextField(
onTap: () {//action of TextField
},
keyboardType: TextInputType.text,
decoration: InputDecoration(
border: InputBorder.none, hintText: 'Password'),
style: Theme.of(context).textTheme.body1,
),
padding: EdgeInsets.only(left: 40),
)),
IconButton(
icon: Icon(Icons.apps),
onPressed: () {//action of iconbutton
},
)
],
)
![enter image description here](https://i.stack.imgur.com/qgzVo.gif)