novyronst/lib/common/help/help_image.dart

89 lines
2.2 KiB
Dart

import 'package:flutter/material.dart';
class ConstImage {
ConstImage._();
/// main
static const String appBottom = "assets/main/app_bottom.png";
static const String pageBg = "assets/main/page_bg.png";
static const String btHomeUnsel = "assets/main/bt_home_unsel.png";
static const String btPlayUnsel = "assets/main/bt_play_unsel.png";
static const String btCollectUnsel = "assets/main/bt_collect_unsel.png";
static const String btMineUnsel = "assets/main/bt_mine_unsel.png";
static const String btHomeSel = "assets/main/bt_home_seled.png";
static const String btPlaySel = "assets/main/bt_play_seled.png";
static const String btCollectSel = "assets/main/bt_collect_seled.png";
static const String btMineSel = "assets/main/bt_mine_seled.png";
static const String spaceImg = "assets/main/space_img.png";
}
class HelpImage {
static Widget asset(
String path, {
BoxFit? fit,
double? width,
double? height,
Color? color,
bool isDartData = false,
String? dartPath,
}) {
return Image.asset(
path,
fit: fit,
width: width,
height: height,
color: color,
);
}
static Widget networkRadius(
String path, {
BoxFit? fit,
double? width,
double? height,
BoxShape? shape,
BorderRadius? borderRadius,
Widget? errorWidget,
}) {
return ClipRRect(
borderRadius: borderRadius ?? BorderRadius.circular(3),
child: network(
path,
fit: fit,
width: width,
height: height,
shape: shape,
errorWidget: errorWidget,
),
);
}
/// load network
static Widget network(
String path, {
BoxFit? fit,
double? width,
double? height,
Color? color,
BoxShape? shape,
BorderRadius? borderRadius,
Widget? errorWidget,
}) {
return FadeInImage.assetNetwork(
placeholder: ConstImage.spaceImg,
image: path,
width: width, height: height, fit: BoxFit.cover,
imageErrorBuilder: (context, error, stackTrace) {
return asset(
ConstImage.spaceImg,
fit: BoxFit.fill,
width: width, height: height
);
},
);
}
}