Sfoglia il codice sorgente

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

tags/0.0.1
Weller 4 anni fa
parent
commit
414671863c
1 ha cambiato i file con 42 aggiunte e 42 eliminazioni
  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 Vedi File

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

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

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

||||||
x
 
000:0
Caricamento…
Annulla
Salva