[英]flutter listview with not displaying with another widget
Followings is my code to display a listview based on data from API call以下是我根据 API 调用的数据显示列表视图的代码
body:onAPICall
? AppWidget().spinner()
: propertyList.length == 0 ||
_IsSearching && searchList.length == 0
? Center(
child: Text(
'No Data',
style: TextStyle(
fontWeight: FontWeight.w600, fontSize: 20),
))
: ListView.builder(
itemCount: propertyList.length,
itemBuilder: (context, index) {
return propertyListData(index);
}),
here onAPICall is a boolean value.这里 onAPICall 是一个 boolean 值。 Now i am able to show the list view or No data properly现在我可以正确显示列表视图或无数据
But i tried to add a textview above the listview as follows但我尝试在列表视图上方添加一个 textview,如下所示
body: SafeArea(
child: Column(children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 15, left: 10, right: 10),
child: ListTile(
dense: true,
title: Text(_currentAddress,
textAlign: TextAlign.start,),
)),
isApiCall
? AppWidget().spinner()
: propertyList.length == 0 ||
_IsSearching && searchList.length == 0
? Center(
child: Text(
'No Related Properties',
style:
TextStyle(fontWeight: FontWeight.w600, fontSize: 20),
))
: ListView.builder(
itemCount: propertyList.length,
itemBuilder: (context, index) {
return propertyListData(index);
}),
]))
Now I am able to see only the Text and appwidget appears but the list of contents are not loading, if there is NO DATA it appears on the top of the page.现在我只能看到文本和 appwidget 出现,但内容列表没有加载,如果没有数据,它会出现在页面顶部。
You have to make sure the ListView
has a size since the Column
doesn't give it a minimum size.您必须确保ListView
有一个大小,因为Column
没有给它一个最小大小。 To fix it wrap the list (and the center) in an Expanded
要修复它,请将列表(和中心)包裹在Expanded
Set ListView
's shrinkWrap
property to true
.将ListView
的shrinkWrap
属性设置为true
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.