我在Windows上制作了一个Flutter应用程序,所有功能都正常,但是当我尝试编译到iOS时,出现了意外错误。在TextField中检测到'onTap'不是正确的参数。我不知道发生了什么,在Windows上不会返回此错误。无论如何,有人知道如何修复这个问题以及正确检测TextField上的'onTap'的方法吗?
new Container(
color: Colors.blue[300],
child: new Padding(
padding: const EdgeInsets.all(8.0),
child: new Card(
child: new ListTile(
leading: new Icon(Icons.search),
title: new TextField(
onTap: () { <--- The named parameter 'onTap' isn´t defined
Navigator.push(
context,
更新
我尝试了这个,但是不起作用。
title: new GestureDetector(
child: new TextField(
controller: searchController,
decoration: new InputDecoration(
hintText: 'Buscar parcela', border: InputBorder.none),
)),
onTap: () {
Navigator.push(
context,
new MaterialPageRoute(
builder: (context) => new EstatesPage(
parcela: widget.parcela,
dropdownItem: dropdownSelection)));
},
更新2: 解决方案
我升级了Flutter和Brew,错误消失了。
CupertinoTextField
Widget 会怎样呢? - anmol.majhailonTap
是最近添加的。https://github.com/flutter/flutter/pull/24536 - Günter Zöchbauercolor: Colors.transparent, child: IgnorePointer( child: TextField( ), ), ),``` 注意不要改变原文的意思。
- Mo Meshkani