'obx does not responsive GetX
I am using GetX. I need when the user delete the image from ui, the card delete. But nothing deleted from UI. if i pressed hot restart it deleted from the UI.
The Code Is:
class SelectedImagesWidget extends GetView<AddProductController> {
@override
Widget build(BuildContext context) {
return Obx(
() => (controller.product.value.pickedImages.isEmpty)
? const SizedBox.shrink()
: SingleChildScrollView(
clipBehavior: Clip.none,
child: SizedBox(
child:ListView.builder(
itemCount: controller.product.value.pickedImages
.length,
itemBuilder: (context, index) {
return Obx(()=>
Stack(
clipBehavior: Clip.none,
children: [
// Image
Card(
clipBehavior: Clip.hardEdge,
child: // AssetThumb(
Image.file(
controller.product.value.pickedImages
.getOrCrash()[index],
),
),
// Delete Button
Positioned(
child: InkWell(
onTap: () async =>
await controller.deleteImage(index),
child: const CircleAvatar(
child: Icon(
Icons.delete_outlined,
),
),
),
);
}
}
Solution 1:[1]
you can use this for refresh list
controller.product.refresh()
Solution 2:[2]
you can use update() function at the end of your logic function in controller
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | mohammad kazemienjad |
Solution 2 | Ahmed Reda AR6 |