obx中的flutter getx rxlist显示窗口小部件
嗨,我在项目上使用GetX。我有rxlist,并且我使用obx显示我的数据:
RxList dasteBandi = [].obs;
void changeTodasteBandi(int index) {
dasteBandi.removeAt(index);
}
和小部件是:
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,
),
),
),
);
},
),
);
当我使用此窗口小部件时,我有此错误:
widegets库捕获的异常 堆栈溢出 相关引起错误的小部件是 GetMaterialApp
堆栈溢出 相关引起错误的小部件是 obx
当我删除这条线时, itemCount:taskcontroller.dastebandi.length, 并用: itemCount:catlist.length,
使用setState()每件事都很好,但是当我将getx控制器用于列表时,我有一个错误
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论