Browse Source

更新商品详情,推荐列表重用

tags/0.0.1
Weller 4 years ago
parent
commit
414671863c
1 changed files with 42 additions and 42 deletions
  1. +42
    -42
      lib/widgets/goods_details/recommend/goods_detail_commend_list.dart

+ 42
- 42
lib/widgets/goods_details/recommend/goods_detail_commend_list.dart View File

@@ -72,7 +72,9 @@ class _GoodsDetailCommendListContainerState
super.didChangeDependencies(); super.didChangeDependencies();
print('didChangeDependencies'); print('didChangeDependencies');
bool isNeedLoadMore = bool isNeedLoadMore =
Provider.of<GoodsDetailsPageNotifier>(context).scrollEnd; Provider
.of<GoodsDetailsPageNotifier>(context)
.scrollEnd;
if (isNeedLoadMore && _provider != '') { if (isNeedLoadMore && _provider != '') {
print('HomeGoods loadmore...'); print('HomeGoods loadmore...');
_bloc.loadMore(_provider); _bloc.loadMore(_provider);
@@ -81,52 +83,50 @@ class _GoodsDetailCommendListContainerState


@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return StreamBuilder<List<HomeGoodsModel>>(
width: double.infinity,
child: StreamBuilder<List<HomeGoodsModel>>(
stream: _bloc.outData, stream: _bloc.outData,
builder: (BuildContext context, AsyncSnapshot snapshot) { builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.data == null) { // if (snapshot.data == null) {
return Container(); // return Container();
} // }


List<HomeGoodsModel> goods = snapshot.data; List<HomeGoodsModel> goods = snapshot.data;
int column = 2; int column = 2;
int count = (goods.length / column).ceil(); int count = ((goods?.length ?? 0) / column).ceil();
return ListView.builder( return SliverList(
shrinkWrap: true, delegate: SliverChildBuilderDelegate((context, index) {
physics: NeverScrollableScrollPhysics(), if (column == 1) {
itemCount: count, return HomeGoodsItemSingle(
itemBuilder: (context, index) { goods[index],
if (column == 1) { _style,
return HomeGoodsItemSingle( data: widget.data,
goods[index], );
_style, } else {
data: widget.data, // return Container(color: Colors.red, height: 126,margin: EdgeInsets.all(10),);
); return Padding(
} else { padding: const EdgeInsets.only(left: 5, right: 5),
// return Container(color: Colors.red, height: 126,margin: EdgeInsets.all(10),); child: Row(
return Padding( children: List.generate(column, (c) {
padding: const EdgeInsets.only(left: 5, right: 5), int i = index * column + c;
child: Row( return Expanded(
children: List.generate(column, (c) { child: i < goods.length
int i = index * column + c; ? HomeGoodsItem(
return Expanded( goods[i],
child: i < goods.length _style,
? HomeGoodsItem( data: widget.data,
goods[i], )
_style, : Container(),
data: widget.data, );
) }).toList(),
: Container(), ),
); );
}).toList(), }
), }, childCount
); :
} count
}); ,
}, ),);
), }
); );
} }
} }

||||||
x
 
000:0
Loading…
Cancel
Save