fix: 缺省图片添加
This commit is contained in:
1 parent
9e10608245
commit
a6b0a2ae95
7 files changed
+183
-26
No files matched your search
@@ -3,6 +3,7 @@ final class ApiConst {
|
||||
|
||||
static const appName = 'Glimzo';
|
||||
static const int pageSize = 12;
|
||||
// https://api-glimzodf.glimzodf.com/glimzodf
|
||||
static const String apiLink = 'https://api-quickeltv.quickeltv.com/quickeltv';
|
||||
|
||||
static String webPrefix = "quickeltv.com";
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import 'dart:io';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:skywood/global/request/api_const.dart';
|
||||
import 'package:skywood/global/request/network_interceptor.dart';
|
||||
import 'package:skywood/utils/tools/app_toast.dart';
|
||||
import 'package:talker_dio_logger/talker_dio_logger.dart';
|
||||
|
||||
import '../../utils/tools/token_manage.dart';
|
||||
|
||||
|
||||
@@ -57,7 +57,9 @@ class DailyQuestWidget extends StatelessWidget {
|
||||
onTap: () {
|
||||
HelpNav.to(DramaDetailPage(dramaBean: drama));
|
||||
},
|
||||
child: HelpImg.network(drama.horizontallyImg, width: 95.w, height: 50.h, fit: BoxFit.cover),
|
||||
child: HelpImg.network(drama.horizontallyImg, width: 95.w, height: 50.h, fit: BoxFit.cover,
|
||||
isWidth: true
|
||||
),
|
||||
);
|
||||
})
|
||||
),
|
||||
@@ -73,7 +75,9 @@ class DailyQuestWidget extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: CommonColor.black, width: 1),
|
||||
),
|
||||
child: HelpImg.network(drama.horizontallyImg, width: 300.w, height: 160.h, fit: BoxFit.cover),
|
||||
child: HelpImg.network(drama.horizontallyImg, width: 300.w, height: 160.h, fit: BoxFit.cover,
|
||||
isWidth: true
|
||||
),
|
||||
),
|
||||
SizedBox(height: 4.h),
|
||||
Row(
|
||||
|
||||
@@ -23,6 +23,9 @@ class ConstImg {
|
||||
static const String noworkImg = "assets/common/nowork_img.png";
|
||||
// applogo
|
||||
static const String appLogo = "assets/common/applogo.png";
|
||||
// space_img_h
|
||||
static const String spaceImgH = "assets/common/space_img_h.png";
|
||||
static const String spaceImgW = "assets/common/space_img_w.png";
|
||||
|
||||
|
||||
static const String homeBg = "assets/imgs/home_bg.png";
|
||||
@@ -137,6 +140,7 @@ class HelpImg {
|
||||
BoxShape? shape,
|
||||
BorderRadius? borderRadius,
|
||||
Widget? errorWidget,
|
||||
bool isWidth = false,
|
||||
}) {
|
||||
return ClipRRect(
|
||||
borderRadius: borderRadius ?? BorderRadius.circular(3),
|
||||
@@ -147,6 +151,7 @@ class HelpImg {
|
||||
height: height,
|
||||
shape: shape,
|
||||
errorWidget: errorWidget,
|
||||
isWidth: isWidth
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -161,6 +166,7 @@ class HelpImg {
|
||||
BoxShape? shape,
|
||||
BorderRadius? borderRadius,
|
||||
Widget? errorWidget,
|
||||
bool isWidth = false,
|
||||
}) {
|
||||
// bool isSvg = path.toLowerCase().endsWith('.svg');
|
||||
// if (isSvg) {
|
||||
@@ -180,6 +186,11 @@ class HelpImg {
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
return FadeInImage.assetNetwork(
|
||||
placeholder: isWidth==true ? ConstImg.spaceImgW : ConstImg.spaceImgH, image: path,
|
||||
width: width, height: height, fit: BoxFit.cover
|
||||
);
|
||||
|
||||
return Image.network(
|
||||
path,
|
||||
width: width,
|
||||
@@ -187,33 +198,17 @@ class HelpImg {
|
||||
fit: fit,
|
||||
loadingBuilder: (context, child, loadingProgress) {
|
||||
if (loadingProgress == null) return child;
|
||||
return SizedBox(
|
||||
width: width, height: height,
|
||||
child: Center(
|
||||
//CircularProgressIndicator
|
||||
child: Container(
|
||||
width: 30,
|
||||
height: 30,
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
strokeWidth: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
return HelpImg.asset(isWidth==true ? ConstImg.spaceImgW : ConstImg.spaceImgH, fit: BoxFit.fill,
|
||||
width: width, height: height
|
||||
);
|
||||
},
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
// ✅ 关键:处理加载失败的情况
|
||||
return errorWidget ??
|
||||
Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
color: Colors.grey[300],
|
||||
child: const Icon(
|
||||
Icons.broken_image,
|
||||
color: Colors.grey,
|
||||
size: 40,
|
||||
SizedBox(
|
||||
width: width, height: height,
|
||||
child: HelpImg.asset(isWidth==true ? ConstImg.spaceImgW : ConstImg.spaceImgH, fit: BoxFit.fill,
|
||||
width: width, height: height
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user