previewImage static method

Widget previewImage(
  1. ImageUploadModel imageUploadModel, {
  2. double? height,
  3. double? width,
  4. EdgeInsets? padding,
  5. EdgeInsets? margin,
})

Implementation

static Widget previewImage(
  ImageUploadModel imageUploadModel, {
  double? height,
  double? width,
  EdgeInsets? padding,
  EdgeInsets? margin,
}) {
  return Container(
    child: imageUploadModel.file == null && imageUploadModel.imageUrl == null
        ? Padding(
            padding: EdgeInsets.only(top: 10.0.h),
            child: Stack(
              alignment: Alignment.topCenter,
              children: [
                Container(
                  width: Get.width.w,
                  height: Get.width.w / 2,
                  decoration: BoxDecoration(
                    color: Get.theme.shadowColor.withAlpha(75),
                    borderRadius: BorderRadius.circular(10.r),
                  ),
                  child: Icon(
                    Icons.broken_image,
                    color: Get.theme.shadowColor,
                  ),
                ),
                Container(
                  width: Get.width.w,
                  padding: EdgeInsets.symmetric(vertical: 5.h),
                  decoration: BoxDecoration(
                    color: Get.theme.shadowColor.withAlpha(100),
                    borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(10.r),
                      topRight: Radius.circular(10.r),
                    ),
                  ),
                  child: Center(
                    child: Texts.caption(imageUploadModel.title),
                  ),
                ),
              ],
            ),
          )
        : InkWell(
            onTap: () {
              if (imageUploadModel.file == null &&
                  imageUploadModel.imageUrl == null) return;
              Get.to(
                  () => HeroPhotoViewRouteWrapper(
                        imageProvider: imageUploadModel.sourceType ==
                                    ImageSourceType.xfile &&
                                imageUploadModel.file != null
                            ? FileImage(
                                File(imageUploadModel.file!.path),
                              )
                            : CachedNetworkImageProvider(
                                imageUploadModel.imageUrl!) as ImageProvider,
                        tag: imageUploadModel.id,
                      ),
                  arguments: imageUploadModel);
            },
            child: Padding(
              padding: EdgeInsets.only(top: 10.h),
              child: Column(
                children: [
                  Container(
                    width: Get.width.w,
                    padding: EdgeInsets.symmetric(vertical: 5.h),
                    decoration: BoxDecoration(
                      color: Get.theme.primaryColor.withAlpha(100),
                      borderRadius: BorderRadius.only(
                        topLeft: Radius.circular(10.r),
                        topRight: Radius.circular(10.r),
                      ),
                    ),
                    child: Center(
                      child: Texts.caption(imageUploadModel.title),
                    ),
                  ),
                  SizedBox(
                    width: Get.width.w,
                    height: Get.width.w / 2,
                    child: Hero(
                      tag: imageUploadModel.id,
                      child: imageUploadModel.sourceType ==
                                  ImageSourceType.xfile &&
                              imageUploadModel.file != null
                          ? ClipRRect(
                              borderRadius: BorderRadius.only(
                                bottomLeft: Radius.circular(10.r),
                                bottomRight: Radius.circular(10.r),
                              ),
                              child: Image.file(
                                File(imageUploadModel.file!.path),
                                fit: BoxFit.fill,
                                height: 50,
                              ),
                            )
                          : ClipRRect(
                              borderRadius: BorderRadius.only(
                                bottomLeft: Radius.circular(10.r),
                                bottomRight: Radius.circular(10.r),
                              ),
                              child: Image.network(
                                imageUploadModel.imageUrl!,
                                fit: BoxFit.cover,
                                height: 50,
                              ),
                            ),
                    ),
                  ),
                ],
              ),
            ),
          ),
  );
}