diff --git a/lib/widgets/home/home_goods/home_goods_item.dart b/lib/widgets/home/home_goods/home_goods_item.dart index a44fa00..2fdb6fa 100644 --- a/lib/widgets/home/home_goods/home_goods_item.dart +++ b/lib/widgets/home/home_goods/home_goods_item.dart @@ -46,13 +46,14 @@ class HomeGoodsItem extends StatelessWidget { Container( width: double.infinity, margin: EdgeInsets.only(right: 0), - child: ClipRRect( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(7.5), - topRight: Radius.circular(7.5)), - child: CachedNetworkImage( - imageUrl: goods?.goodImage ?? '', - fit: BoxFit.fitWidth, + child: ClipRRect(borderRadius: BorderRadius.only(topLeft: Radius.circular(7.5), topRight: Radius.circular(7.5)), + child: CachedNetworkImage(imageUrl: goods?.goodImage ?? '', fit: BoxFit.fitWidth, + placeholder: (context, url) { + return _createShimmerWidget(width: double.infinity); + }, + errorWidget: (context, url, error,) { + return _createShimmerWidget(width: double.infinity); + }, ), ), ), @@ -352,4 +353,16 @@ class HomeGoodsItem extends StatelessWidget { style: TextStyle(fontSize: 11, color: HexColor.fromHex('#999999')), ); } + + /// 商品占位骨架视图 + Widget _createShimmerWidget({double width, double height}) { + //修改后返回默认图片 + return Image.asset( + 'assets/images/occupation_map/occupation_map.png', + package: 'zhiying_base_widget', + width: width, + height: height, + fit: BoxFit.fill, + ); + } } diff --git a/lib/widgets/home/home_goods/home_goods_item_single.dart b/lib/widgets/home/home_goods/home_goods_item_single.dart index 8dc6b31..7670128 100644 --- a/lib/widgets/home/home_goods/home_goods_item_single.dart +++ b/lib/widgets/home/home_goods/home_goods_item_single.dart @@ -59,6 +59,12 @@ class HomeGoodsItemSingle extends StatelessWidget { child: CachedNetworkImage( imageUrl: goods.goodImage, fit: BoxFit.fitHeight, + placeholder: (context, url) { + return _createShimmerWidget(width: double.infinity, height: double.infinity); + }, + errorWidget: (BuildContext context, String url, dynamic error) { + return _createShimmerWidget(width: double.infinity, height: double.infinity); + }, ), ), ), @@ -427,4 +433,17 @@ class HomeGoodsItemSingle extends StatelessWidget { ], ); } + + /// 商品占位骨架视图 + Widget _createShimmerWidget({double width, double height}) { + //修改后返回默认图片 + return Image.asset( + 'assets/images/occupation_map/occupation_map.png', + package: 'zhiying_base_widget', + width: width, + height: height, + fit: BoxFit.fill, + ); + } + } diff --git a/lib/widgets/search_result/goods_list/bloc/search_result_goods_list_bloc.dart b/lib/widgets/search_result/goods_list/bloc/search_result_goods_list_bloc.dart index 9430d19..c9c2d50 100644 --- a/lib/widgets/search_result/goods_list/bloc/search_result_goods_list_bloc.dart +++ b/lib/widgets/search_result/goods_list/bloc/search_result_goods_list_bloc.dart @@ -35,8 +35,8 @@ class SearchResultGoodsListBloc extends Bloc _mapOnLoadToState(SearchResultGoodsListOnLoadEvent event, SearchResultGoodsListLoadedState state) async* { + Stream _mapOnLoadToState(SearchResultGoodsListOnLoadEvent event) async* { var result = await repository.fetchLoadData(); if (!EmptyUtil.isEmpty(result)) { yield SearchResultGoodsListLoadSuccessState(); @@ -93,7 +93,7 @@ class SearchResultGoodsListBloc extends Bloc= MAX) { + if ((data?.length ?? 0) > 0) { _hasNomore = true; ++_currentPage; } else {