|
|
@@ -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 |
|
|
|
, |
|
|
|
),); |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
} |