documentCard static method
Widget
documentCard(
- ImageUploadModel imageUploadModel,
- VoidCallback clickHandler, {
- bool useBorder = true,
Implementation
static Widget documentCard(
ImageUploadModel imageUploadModel,
VoidCallback clickHandler, {
bool useBorder = true,
}) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
margin: EdgeInsets.only(top: 10.h),
decoration: BoxDecoration(
color: Get.theme.colorScheme.background,
borderRadius: BorderRadius.all(Radius.circular(10.r)),
border: !useBorder
? null
: Border.all(
width: 1.w,
color: imageUploadModel.valid
? Get.theme.shadowColor
: Get.theme.colorScheme.error,
),
boxShadow: useBorder
? null
: [
BoxShadow(
color: Colors.black.withOpacity(0.07),
offset: const Offset(0.0, 1.0), //(x,y)
blurRadius: 6.0,
),
],
),
// padding: EdgeInsets.all(20),
child: ListTile(
tileColor: Colors.transparent,
visualDensity: VisualDensity.compact,
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);
},
contentPadding: imageUploadModel.text == null
? const EdgeInsets.symmetric(vertical: 8, horizontal: 16)
: null,
leading: imageUploadModel.file == null &&
imageUploadModel.imageUrl == null
? const SizedBox(
width: 100,
child: Icon(
Icons.image_not_supported,
size: 50,
color: Colors.grey,
),
)
: SizedBox(
width: 100,
child: ClipRRect(
borderRadius: BorderRadius.circular(10.0),
child: Hero(
tag: imageUploadModel.id,
child: imageUploadModel.sourceType ==
ImageSourceType.xfile &&
imageUploadModel.file != null
? Image.file(
File(imageUploadModel.file!.path),
fit: BoxFit.scaleDown,
height: 50,
)
: Image.network(
imageUploadModel.imageUrl!,
fit: BoxFit.scaleDown,
height: 50,
)),
),
),
title: Texts.caption(
imageUploadModel.title,
textOverflow: TextOverflow.visible,
),
subtitle: imageUploadModel.text == null
? null
: Texts.overline(
imageUploadModel.text ?? "",
textOverflow: TextOverflow.visible,
),
trailing: IconButton(
onPressed: clickHandler,
icon: const Icon(Icons.add_a_photo),
),
),
),
AnimatedSize(
duration: const Duration(milliseconds: 300),
child: !imageUploadModel.valid
? Padding(
padding: const EdgeInsets.all(8.0),
child: Texts.overline(
"Gambar wajib disertakan",
color: Get.theme.colorScheme.error,
),
)
: const SizedBox(
height: 10,
),
),
],
);
}