[英]Flutter: InkWell does not detect tap
我正在編寫第一個帶有顫動的應用程序,並且遇到了InkWell在點擊時沒有檢測到的問題。 這是一個比我能找到的例子更復雜的結構。 我寫了以下函數:
class ChatOverviewElements {
static Widget buildChatEntry(BuildContext context, String username,
String lastMessageText,
String lastMessageDate, bool group,
int unread, int chatID) {
return new Material(
child: new Ink(
padding: const EdgeInsets.only(right: 32.0),
child: new InkWell(
onTap: ChatOverviewNavigation.openChat(context, chatID),
child: new Row(
children: <Widget>[
new Container(
padding: const EdgeInsets.all(10.0),
child: new Icon(
Icons.account_circle,
size: 60.0,
),
),
new Expanded (
child: new Container(
padding: const EdgeInsets.only(right: 5.0),
height: 60.0,
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Row(
children: <Widget>[
group ? new Icon(Icons.group) : new Container(),
new Container(width: group ? 10.0 : 0.0,),
TextStyles.username(username),
],
),
TextStyles.chatSnippet(lastMessageText),
],
),
),
),
new Column(
children: <Widget>[
new Row(
children: <Widget>[
new Icon(
Icons.done_all,
color: Colors.green,
),
new Container(width: 8.0,),
TextStyles.chatDate(lastMessageDate),
]),
new Icon(
Icons.thumb_up,
color: Colors.grey[500],
)
],
),
],
),
),
),
);
}
}
它創建了一個像你在WhatsApp等中看到的框,其中包含用戶名,消息預覽,未讀徽章(拇指向上圖標是占位符)等等。 我希望它可以替換那個外部容器,所以我改變了它並且墨水(看到漣漪)並添加了InkWell和其他所有東西作為那個孩子。 這不起作用。 它沒有檢測到一個全部,我不明白為什么。
調用構建函數來創建ListView的子代,它本身嵌套在Scaffold和Material App中。 不過這應該沒關系,我在ListView中嘗試了StackOverflow的簡單示例,這些示例工作得很好。
所以問題是:我在這里做錯了什么? 那個InkWell必須在哪里,所以整個容器都是可取的,容器背景上會出現波紋?
onTap: ChatOverviewNavigation.openChat(context, chatID),
應該
onTap: () => ChatOverviewNavigation.openChat(context, chatID),
否則ChatOverviewNavigation.openChat(context, chatID)
將用作onTap
處理程序。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.