'flutter getx rxlist in obx error show widget
hi i am using getx on my project . I have RxList and i use Obx for shows my data :
RxList dasteBandi = [].obs;
void changeTodasteBandi(int index) {
dasteBandi.removeAt(index);
}
and widget is :
Obx(
() => ListView.builder(
// itemCount: catList.length,
itemCount: taskController.dasteBandi.length,
itemBuilder: (context, index) {
return Container(
decoration: BoxDecoration(
color: themeController.isDark.value == true
? Colors.black.withOpacity(0.3)
: Colors.white.withOpacity(0.8),
borderRadius: BorderRadius.circular(16)),
margin: EdgeInsets.symmetric(vertical: 1.h),
child: ListTile(
// title: Text(catList[index]),
title: Text(taskController.dasteBandi[index]),
leading: IconButton(
onPressed: () {
print(index);
// setState(() {
// catList.removeAt(index);
// });
taskController.changeTodasteBandi(index);
},
icon: Icon(
Icons.remove_circle_sharp,
color: MyUtils.kRedColor,
),
),
),
);
},
),
);
when i use this widget i have this error :
Exception caught by widgets library Stack Overflow The relevant error-causing widget was GetMaterialApp
Stack Overflow The relevant error-causing widget was Obx
when i am remove this line itemCount: taskController.dasteBandi.length, and changed it with: itemCount: catList.length,
and use setState() every thing is fine but when i use getx controller for list i have that error
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
