如何解决如何在列内显示列表视图?
在我的应用程序个人资料页面中,有3个容器。第一个容器显示“个人资料图片”和“名称”。 第二个容器,带有一个带有3个值(帖子,类别和个人资料)的下拉按钮。 第三个容器中有一个专栏作为孩子。我想将listview构建器用于帖子和类别,并且个人资料已准备就绪并且可以完美显示。我在子栏内使用了以下代码
Container(
padding: EdgeInsets.only(top: 10.0),width: double.infinity,child: Column(
mainAxisAlignment: MainAxisAlignment.start,children: [
_selectedItem == "posts" ?
"I want to use listview builder here"
:
Container(
height: 0.0,child: Text(""),),_selectedItem == "categories" ?
"I want to use listview builder here"
:
Container(
height: 0.0,_selectedItem == "profile" ?
"this is working fine and able to see output"
:
Container(
height: 0.0,],
即使在stackoverflow上,我也搜索了许多示例,但找不到任何符合我需要的示例。从服务器获取个人资料信息,帖子和类别,并将其存储在var userProfile中;列出userPosts = new List();列出postCategories = new List();分别。我尝试了许多示例来满足我的需要,尽管这不是我的要求,但给出了错误。
如果有人能给我解决方案,我将不胜感激。 预先感谢
解决方法
您想在其中添加列表的任何地方,只需将此代码粘贴到此处,即可正常工作。
ListView.builder(
shrinkWrap: true,//If you get infinite height error use this attribute,it will shrink height of the list to display only available items.
physics: NeverScrollableScrollPhysics(),//if you want to disable scrolling
itemBuilder: (context,index) {
return Text(NamesList[index].name); //Here NamesList is your data list
},)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。