Android 颤振:墨水池未检测到水龙头
我正在用flifter编写我的第一个应用程序,遇到了一个问题,墨水瓶在被敲击时无法检测到。这是一个比我能找到的例子更复杂的结构。我编写了以下函数:Android 颤振:墨水池未检测到水龙头,android,user-interface,dart,flutter,Android,User Interface,Dart,Flutter,我正在用flifter编写我的第一个应用程序,遇到了一个问题,墨水瓶在被敲击时无法检测到。这是一个比我能找到的例子更复杂的结构。我编写了以下函数: class ChatOverviewElements { static Widget buildChatEntry(BuildContext context, String username, String lastMessageText, String lastMessageDate, bool group,
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],
)
],
),
],
),
),
),
);
}
}
class ChatOverview元素{
静态小部件buildChatEntry(BuildContext上下文、字符串用户名、,
字符串lastMessageText,
字符串lastMessageDate,布尔组,
int未读,int chatID){
退回新材料(
孩子:新墨水(
填充:仅限常量边集(右:32.0),
孩子:新墨水井(
onTap:ChatOverviewNavigation.openChat(上下文,chatID),
孩子:新的一排(
儿童:[
新容器(
填充:常数边集全部(10.0),
孩子:新图标(
Icons.account_圈,
尺寸:60.0,
),
),
新扩展(
子容器:新容器(
填充:仅限常量边集(右:5.0),
身高:60.0,
子:新列(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
新行(
儿童:[
组?新图标(Icons.group):新容器(),
新容器(宽度:组?10.0:0.0,),
TextStyles.username(用户名),
],
),
TextStyles.chatSnippet(lastMessageText),
],
),
),
),
新专栏(
儿童:[
新行(
儿童:[
新图标(
图标。全部完成,
颜色:颜色。绿色,
),
新容器(宽度:8.0,),
TextStyles.chatDate(lastMessageDate),
]),
新图标(
图标。竖起大拇指,
颜色:颜色。灰色[500],
)
],
),
],
),
),
),
);
}
}
它创建了一个如WhatsApp等中所示的框,其中包含用户名、消息预览、未读徽章(拇指朝上图标是该图标的占位符)等等。我希望它的外部容器是可敲击的,所以我把它改成了墨水(为了看到波纹),并添加了墨水井和其他所有东西,作为那口井的孩子。这是行不通的。它没有检测到所有的水龙头,我不明白为什么
调用build函数来创建ListView的子级,ListView本身嵌套在脚手架和材质应用程序中。不过这不要紧,我在ListView中尝试了StackOverflow的简单示例,这些都很好
所以问题是:我做错了什么?墨水池必须在哪里才能使整个容器都可以贴取,并且容器背景上会显示波纹
onTap: ChatOverviewNavigation.openChat(context, chatID),
应该是
onTap: () => ChatOverviewNavigation.openChat(context, chatID),
否则,
ChatOverviewNavigation.openChat(context,chatID)
的结果将被用作onTap
处理程序。就是这样。我经常以正确的方式看到它,只是没有意识到。无论如何,谢谢你的帮助!原始代码中是否有分析器错误?我也很好奇,尤其是最近有一个类似的问题。没有,没有显示任何内容,否则我不会问。