Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firebase 如何在列表视图生成器中显示3个文本小部件?_Firebase_Flutter_Google Cloud Firestore - Fatal编程技术网

Firebase 如何在列表视图生成器中显示3个文本小部件?

Firebase 如何在列表视图生成器中显示3个文本小部件?,firebase,flutter,google-cloud-firestore,Firebase,Flutter,Google Cloud Firestore,我试图显示一个包含3个文本小部件的listviewbuilder。但是最后一个文本小部件看起来不太好。这是它的样子 这是我的密码 @override Widget build(BuildContext context) { final user = Provider.of<Userforid>(context); if (nosuerfound == true) { return ListView.builder( item

我试图显示一个包含3个文本小部件的listviewbuilder。但是最后一个文本小部件看起来不太好。这是它的样子

这是我的密码


  @override
  Widget build(BuildContext context) {
    final user = Provider.of<Userforid>(context);
    if (nosuerfound == true) {
      return ListView.builder(
          itemCount: _resultsList.length,
          itemBuilder: (BuildContext context, int index) {
            return Padding(
              padding: const EdgeInsets.fromLTRB(0, 0, 0, 10),
              child: ListTile(
                onTap: () {
                  DatbaseService.instance
                      .createorGetConversation(user.uid, _resultsList[index].id,
                          (String _conversationID) {
                    /*    NavigationService.instance.navigateToRoute(
                            MaterialPageRoute(builder: (context) {
                              return MeineBeitraege(
                                  _conversationID,
                                  _resultsList[index].id,
                                  _resultsList[index].data()['username'],
                                
                                 );
                            }),
                          );*/
                  });
                },
                leading: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Expanded(
                      child: Container(
                        child: Text(
                          _resultsList[index].data()['hashtag1'],
                          style: const TextStyle(
                            fontWeight: FontWeight.w500,
                            fontSize: 20.0,
                          ),
                        ),
                      ),
                    ),
                    Expanded(
                      child: Container(
                        child: Text(
                          _resultsList[index].data()['hashtag2'],
                          style: const TextStyle(
                            fontWeight: FontWeight.w500,
                            fontSize: 20.0,
                          ),
                        ),
                      ),
                    ),
                    Expanded(
                      child: Container(
                        child: Text(
                          _resultsList[index].data()['hashtag3'],
                          style: const TextStyle(
                            // fontWeight: FontWeight.w500,
                            fontSize: 20.0,
                          ),
                        ),
                      ),
                    ),
                  ],
                ),

                // subtitle: Text(_resultsList[index].data()['email']),
              ),
            );
          });
    } else {
      return Padding(
        padding: const EdgeInsets.fromLTRB(0, 30, 0, 0),
        child: Container(
            child: Text(
          "No Hashtag found",
          style: TextStyle(fontSize: 16),
        )),
      );
    }
  }
}

@凌驾
小部件构建(构建上下文){
最终用户=提供者(上下文);
if(nosuerfound==true){
返回ListView.builder(
itemCount:\u resultsList.length,
itemBuilder:(构建上下文,int索引){
返回填充(
padding:const EdgeInsets.fromLTRB(0,0,0,10),
孩子:ListTile(
onTap:(){
DatbaseService.instance
.createorGetConversation(user.uid,_resultsList[index].id,
(字符串\u会话ID){
/*NavigationService.instance.navigateToRoute(
MaterialPage路线(生成器:(上下文){
返回MeineBeitraege(
_会话ID,
_结果列表[index].id,
_结果列表[index].data()['username'],
);
}),
);*/
});
},
前导:列(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
扩大(
子:容器(
子:文本(
_结果列表[index].data()['hashtag1'],
样式:consttextstyle(
fontWeight:fontWeight.w500,
字体大小:20.0,
),
),
),
),
扩大(
子:容器(
子:文本(
_结果列表[index].data()['hashtag2'],
样式:consttextstyle(
fontWeight:fontWeight.w500,
字体大小:20.0,
),
),
),
),
扩大(
子:容器(
子:文本(
_结果列表[index].data()['hashtag3'],
样式:consttextstyle(
//fontWeight:fontWeight.w500,
字体大小:20.0,
),
),
),
),
],
),
//字幕:文本(_resultsList[index].data()['email']),
),
);
});
}否则{
返回填充(
padding:const EdgeInsets.fromLTRB(0,30,0,0),
子:容器(
子:文本(
“未找到标签”,
样式:TextStyle(字体大小:16),
)),
);
}
}
}

所以我想要的是在列中的每个文本小部件之间得到一点填充。最后一个标签也应该正确显示。未显示一半。希望任何人都能提供帮助。如果您需要更多信息,请留下评论。

您不需要使用ListTile来显示尾随中的三个元素,请使用自定义小部件或带有手势检测器的简单容器(或用于材质点击效果的InkWell)。 扩展的小部件也不需要

ListView.builder(
itemCount:\u resultsList.length,
itemBuilder:(构建上下文,int索引){
返回容器(
padding:const EdgeInsets.fromLTRB(0,0,0,10),
边距:const EdgeInsets.all(10.0),//添加边距
孩子:InkWell(
onTap:(){
/*DatbaseService.instance
.createorGetConversation(user.uid,_resultsList[index].id,
(字符串\u会话ID){
/*NavigationService.instance.navigateToRoute(
MaterialPage路线(生成器:(上下文){
返回MeineBeitraege(
_会话ID,
_结果列表[index].id,
_结果列表[index].data()['username'],
);
}),
);*/
});*/
},
子:列(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
正文(
_结果列表[index].data()['hashtag1'],
“文本1”,
样式:consttextstyle(
fontWeight:fontWeight.w500,
字体大小:15.0,
),
),
正文(
_结果列表[index].data()['hashtag2'],
样式:consttextstyle(
fontWeight:fontWeight.w500,
字体大小:15.0,
),
),
正文(
_结果列表[index].data()['hashtag3'],
样式:consttextstyle(
//fontWeight:fontWeight.w500,
字体大小:15.0,
),
),
],
),
),
);
},
),

好的,但我不能再点击了,还有3个hashtag之间的填充。像这个标签一样,我更新了mi解决方案。删除SizedBox并向容器添加边距。要获得点击效果,请使用墨水池而不是手势检测器。祝您度过一个愉快的夜晚:)