ListView.builder 不能在列内工作
ListView.builder don't work inside a Column
当我将 ListView.builder 或 GridView.builder 放入列中时,我的应用程序性能“下降”
我的代码是这样的
Scafold(
body:RefreshIndicator(
onRefresh: () {
return refreshUI(setState,);
},
child: SingleChildScrollView(
controller: scrollController,
child: Column(
children: [
ListView.builder(
itemCount: productListObj.length,
itemBuilder: (BuildContext context, int index) {
return InkWell(
onTap: (){
showDialog(context: context, builder:
(BuildContext context){
return DetailsProducts(context,productListObj[index]);
});
},
child: cards(index)
);
})
),
//Other Widgets
]
)
)
)
ListView是一个图片商品列表,向下滚动很多时流动性下降,所以我改成
Scafold(
body:RefreshIndicator(
onRefresh: () {
return refreshUI(setState,);
},
child:
ListView.builder(
controller: scrollController,
itemCount: productListObj.length,
itemBuilder: (BuildContext context, int index) {
return
InkWell(
onTap: (){
showDialog(context: context, builder: (BuildContext context){
return DetailsProducts(context,productListObj[index]);
});
},
child: cards(index, price)
);
}
),
)
)
但是,现在我的列表下没有其他小部件了。
我不明白为什么会这样...
你真的不应该将 ListView 与 SingleChildScrollView
和 Column
一起使用 - 它有点像一个或另一个:
我觉得我分享给大家的视频讲得很清楚了
return Scaffold(
body: SafeArea(
child: RefreshIndicator(
onRefresh: () {
return refreshUI(
setState,
);
},
child: ListView.builder(
itemCount: productListObj.length,
itemBuilder: (BuildContext context, int index) {
return InkWell(
onTap: () {
showDialog(
context: context,
builder: (BuildContext context) {
return DetailsProducts(
context, productListObj[index]);
});
},
child: cards(index));
})),
//Other Widgets
),);
当我将 ListView.builder 或 GridView.builder 放入列中时,我的应用程序性能“下降”
我的代码是这样的
Scafold(
body:RefreshIndicator(
onRefresh: () {
return refreshUI(setState,);
},
child: SingleChildScrollView(
controller: scrollController,
child: Column(
children: [
ListView.builder(
itemCount: productListObj.length,
itemBuilder: (BuildContext context, int index) {
return InkWell(
onTap: (){
showDialog(context: context, builder:
(BuildContext context){
return DetailsProducts(context,productListObj[index]);
});
},
child: cards(index)
);
})
),
//Other Widgets
]
)
)
)
ListView是一个图片商品列表,向下滚动很多时流动性下降,所以我改成
Scafold(
body:RefreshIndicator(
onRefresh: () {
return refreshUI(setState,);
},
child:
ListView.builder(
controller: scrollController,
itemCount: productListObj.length,
itemBuilder: (BuildContext context, int index) {
return
InkWell(
onTap: (){
showDialog(context: context, builder: (BuildContext context){
return DetailsProducts(context,productListObj[index]);
});
},
child: cards(index, price)
);
}
),
)
)
但是,现在我的列表下没有其他小部件了。
我不明白为什么会这样...
你真的不应该将 ListView 与 SingleChildScrollView
和 Column
一起使用 - 它有点像一个或另一个:
我觉得我分享给大家的视频讲得很清楚了
return Scaffold(
body: SafeArea(
child: RefreshIndicator(
onRefresh: () {
return refreshUI(
setState,
);
},
child: ListView.builder(
itemCount: productListObj.length,
itemBuilder: (BuildContext context, int index) {
return InkWell(
onTap: () {
showDialog(
context: context,
builder: (BuildContext context) {
return DetailsProducts(
context, productListObj[index]);
});
},
child: cards(index));
})),
//Other Widgets
),);