getAssets static method

Widget getAssets(
  1. String assetName, {
  2. Key? key,
  3. double? width,
  4. double? height,
  5. bool? isCustom = false,
  6. PathFormat pathFormat = PathFormat.icons,
  7. ImageFormat format = ImageFormat.png,
  8. BoxFit fit = BoxFit.contain,
  9. Color? color,
  10. void click()?,
})

Implementation

static Widget getAssets(
  String assetName, {
  Key? key,
  double? width,
  double? height,
  bool? isCustom = false,
  PathFormat pathFormat = PathFormat.icons,
  ImageFormat format = ImageFormat.png,
  BoxFit fit = BoxFit.contain,
  Color? color,
  void Function()? click,
}) {
  return GestureDetector(
    onTap: click != null
        ? () {
            click.call();
          }
        : null,
    child: format == ImageFormat.svg
        ? SvgPicture.asset(
            key: key,
            isCustom!
                ? assetName
                : 'assets/${pathFormat.name}/$assetName.${format.name}',
            width: width,
            height: height,
            colorFilter: color != null
                ? ColorFilter.mode(
                    color,
                    BlendMode.srcIn,
                  )
                : null,
            fit: fit,
          )
        : Image.asset(
            isCustom!
                ? assetName
                : 'assets/${pathFormat.name}/$assetName.${format.name}',
            key: key,
            width: width,
            height: height,
            fit: fit,
            color: color,
          ),
  );
}