image method
Widget
image(
{ - dynamic component,
- required double parentWidth,
})
Implementation
Widget image({var component, required double parentWidth}) {
ImageController controller = ImageController();
return Obx(() {
if (component["value"] != null && component["value"] != "") {
controller.imageFile.value = component["value"];
}
return SizedBox(
width: (component["cssClass"] != null && component["cssClass"] != "")
? SwitchCase().componentWidthSC(
component["cssClass"],
{
"layout_1by8_col": Get.width * 0.1,
"layout_1_col": Get.width * 0.2,
"layout_2_col": Get.width * 0.4,
"layout_3_col": Get.width * 0.68,
"layout_4_col": Get.width,
},
parentWidth * 0.2)
: parentWidth * 0.2,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AltComponent().altComponentLabel(
component: component,
label: (component["security"] != null &&
component["security"]["fieldLabel"] != null &&
component["security"]["fieldLabel"] != "")
? component["security"]["fieldLabel"]
: component["name"]),
Row(
children: [
TextButton(
onPressed: () {
controller.uploadImage();
},
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
minimumSize: const Size(30, 30),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
alignment: Alignment.centerLeft),
child: Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(componentBorderRadius),
color: Palette.buttonComponentColor),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: attachmentHorizontalSpacing,
vertical: attachmentVerticalSpacing),
child: Text("Upload Image",
style: attachmentButtonComponentTxtStyle),
),
),
),
controller.imageFile.value != ""
? Padding(
padding: const EdgeInsets.only(left: 6.0),
child: CircleAvatar(
backgroundImage:
AssetImage(controller.imageFile.value),
minRadius: 15,
),
)
: Padding(
padding: const EdgeInsets.only(left: 6.0),
child: Image.asset(
"assets/images/noimage.png",
scale: 3,
),
)
],
),
AltComponent().altComponentInstruction(component: component)
],
),
);
});
}