Browse Source

1223 商品详情图返回错误时去掉占位图片

tags/0.0.3+1
23028876916@qq.com 3 years ago
parent
commit
6eda82d30f
1 changed files with 22 additions and 21 deletions
  1. +22
    -21
      lib/widgets/goods_details/detail_img/goods_details_img.dart

+ 22
- 21
lib/widgets/goods_details/detail_img/goods_details_img.dart View File

@@ -19,8 +19,7 @@ class GoodsDetailsImgWidget extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocProvider<GoodsDetailsImgBloc>( return BlocProvider<GoodsDetailsImgBloc>(
create: (_) =>
GoodsDetailsImgBloc(repository: GoodsDetailsImgRepository()),
create: (_) => GoodsDetailsImgBloc(repository: GoodsDetailsImgRepository()),
//..add(GoodsDetailsImgInitEvent(model: model)), //..add(GoodsDetailsImgInitEvent(model: model)),
child: GoodsDetailsImgWidgetContainer( child: GoodsDetailsImgWidgetContainer(
model, model,
@@ -36,16 +35,13 @@ class GoodsDetailsImgWidgetContainer extends StatefulWidget {
const GoodsDetailsImgWidgetContainer(this.model, {Key key}) : super(key: key); const GoodsDetailsImgWidgetContainer(this.model, {Key key}) : super(key: key);


@override @override
_GoodsDetailsImgWidgetContainerState createState() =>
_GoodsDetailsImgWidgetContainerState();
_GoodsDetailsImgWidgetContainerState createState() => _GoodsDetailsImgWidgetContainerState();
} }


class _GoodsDetailsImgWidgetContainerState
extends State<GoodsDetailsImgWidgetContainer> {
class _GoodsDetailsImgWidgetContainerState extends State<GoodsDetailsImgWidgetContainer> {
@override @override
void initState() { void initState() {
BlocProvider.of<GoodsDetailsImgBloc>(context)
.add(GoodsDetailsImgInitEvent(model: widget?.model));
BlocProvider.of<GoodsDetailsImgBloc>(context).add(GoodsDetailsImgInitEvent(model: widget?.model));
super.initState(); super.initState();
} }


@@ -99,8 +95,7 @@ class _GoodsDetailsImgWidgetContainerState
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
if (item != null) { if (item != null) {
PhotoPreview.showPhotoPreviewByimages(context, [item],
currentIndex: 0, heroTagSuffix: "bottom");
PhotoPreview.showPhotoPreviewByimages(context, [item], currentIndex: 0, heroTagSuffix: "bottom");
} }
}, },
child: Hero( child: Hero(
@@ -109,18 +104,27 @@ class _GoodsDetailsImgWidgetContainerState
imageUrl: item ?? '', imageUrl: item ?? '',
fit: BoxFit.fitWidth, fit: BoxFit.fitWidth,
// 默认default图片 // 默认default图片
placeholder: (context, url){
placeholder: (context, url) {
return AspectRatio( return AspectRatio(
aspectRatio: 1/1,
child: _shimmerWidget(height: double.infinity, width: double.infinity,),
aspectRatio: 1 / 1,
child: _shimmerWidget(
height: double.infinity,
width: double.infinity,
),
); );
}, },
progressIndicatorBuilder: (context, url ,progress){
progressIndicatorBuilder: (context, url, progress) {
return AspectRatio( return AspectRatio(
aspectRatio: 1/1,
child: _shimmerWidget(height: double.infinity, width: double.infinity,),
aspectRatio: 1 / 1,
child: _shimmerWidget(
height: double.infinity,
width: double.infinity,
),
); );
}, },
errorWidget: (BuildContext context, String url, dynamic error) {
return Container();
},
), ),
)); ));
}).toList(), }).toList(),
@@ -136,8 +140,7 @@ class _GoodsDetailsImgWidgetContainerState
color: Colors.white, color: Colors.white,
margin: const EdgeInsets.only(top: 6), margin: const EdgeInsets.only(top: 6),
width: double.infinity, width: double.infinity,
padding:
const EdgeInsets.only(top: 15, bottom: 15, left: 12.5, right: 12.5),
padding: const EdgeInsets.only(top: 15, bottom: 15, left: 12.5, right: 12.5),
child: _getLeftWidget(model), child: _getLeftWidget(model),
); );
} }
@@ -152,9 +155,7 @@ class _GoodsDetailsImgWidgetContainerState
), ),
const SizedBox(width: 2.5), const SizedBox(width: 2.5),
Text(model?.title ?? '商品详情', Text(model?.title ?? '商品详情',
style: TextStyle(
color: HexColor.fromHex(model?.title_color ?? '#333333'),
fontSize: 12)),
style: TextStyle(color: HexColor.fromHex(model?.title_color ?? '#333333'), fontSize: 12)),
], ],
); );
} }


Loading…
Cancel
Save