GET_IMAGE_FILE function

Widget GET_IMAGE_FILE(
  1. File imageFile,
  2. dynamic customHeight,
  3. dynamic customWidth,
  4. dynamic iconDefault,
  5. dynamic customRadius, {
  6. Color? iconColor,
})

Implementation

Widget GET_IMAGE_FILE(File imageFile, customHeight, customWidth, iconDefault, customRadius, {Color? iconColor}) {
  double width = (customWidth ?? 50) + .0; // + .0 for to convert int to double
  double height = (customHeight ?? 50) + .0;

  return StatefulBuilder( builder: (BuildContext context, StateSetter setStateModal ) {
    ColorScheme colorScheme = Theme.of(context).colorScheme;
    Icon icon = Icon(iconDefault, size: width+12, color: (iconColor ?? colorScheme.onBackground).withOpacity(.6) );

    return ClipRRect(
      borderRadius: BorderRadius.circular(customRadius+.0),
      child: imageFile.toString() == ''
      ? icon
      : Image.file(
          imageFile, width: width, height: height,
          errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
            developer.log('page_manager -> getImageFile() error');
            developer.log(exception.toString());
            return icon;
          }
        )
    );
  });
}