appIcon function

Widget appIcon({
  1. required String assetName,
  2. double iconSize = 28.0,
  3. VoidCallback? onPressed,
  4. double padding = 8.0,
  5. ImageType imageType = ImageType.SVG,
})

Implementation

Widget appIcon(
    {required String assetName,
    double iconSize = 28.0,
    VoidCallback? onPressed,
    double padding = 8.0,
    ImageType imageType = ImageType.SVG}) {
  return imageType == ImageType.SVG
      ? IconButton(
          padding: EdgeInsets.all(padding),
          constraints: BoxConstraints(),
          icon: SvgPicture.asset(
            assetName,
            width: iconSize - 8,
            height: iconSize - 8,
          ),
          onPressed: onPressed,
          iconSize: iconSize,
        )
      : GestureDetector(
          onTap: onPressed,
          child: Image.asset(
            assetName,
            fit: BoxFit.cover,
            height: iconSize,
            width: iconSize,
          ));
}