问题描述
我正在使用 InteractiveScrollViewer 并且列表没有在添加和更新功能上更新,所以我将 StatefulBuilder 用于 CardList。现在它在同一页面上工作正常,但是如果我推送另一个页面,即 endDrawer 并在我弹出页面时在那里更新项目,页面中不会显示任何效果。
StatefulBuilder(
builder:
(BuildContext context,StateSetter _setState) =>
我正在更新抽屉关闭时运行的某个函数中的项目列表。我无法在此函数中发送 _setstate,因为此函数是全局函数。
我可以对嵌套滚动视图使用哪些其他技术。
编辑:
bloc.getAllFoodItems(_id).then((value) {
if (!mounted) return;
setState(() {
_itemList = value;
if (menuItemsList != null && menuItemsList.length != 0)
for (int i = 0; i < menuItemsList.length; i++) {
if (menuItemsList[i].id != null) {
int ls = -1;
if (_itemList != null)
ls = _itemList
.indexWhere((item) => item.itemID == menuItemsList[i].id);
if (ls != -1) {
setState(() {
menuItemsList[i].quantity = _itemList[ls].quantity;
});
} else
setState(() {
menuItemsList[i].quantity = 0;
});
}
}
});
});
此代码在绘图关闭时运行。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)