简体   繁体   English

我如何获得 Provider.of 的 memberId

[英]How I can get memberId for Provider.of

Heloo everybody.大家好。 I want to ask you, how i can delete my ListView item,and send this to the Provider.of<Members>(context)我想问你,我如何删除我的 ListView 项目,并将其发送给 Provider.of<Members>(context)

I used to try many variants of changing.我曾经尝试过许多变化的变体。 But in some case i get 'a dismissed dismissible widget is still part of the tree' error.但在某些情况下,我会收到“一个已关闭的可关闭小部件仍然是树的一部分”错误。 In another after restate my ListView stay without change.在另一个重述之后,我的 ListView 保持不变。 I understan that problem is Provide to 'void removeMember' member id.我明白问题是提供给“void removeMember”成员 ID。

GitHub url https://github.com/Rodion98/wor_app.git GitHub 网址https://github.com/Rodion98/wor_app.git

your delete item logic is wrong, just try this你的删除项目逻辑是错误的,试试这个

void removeMember(String memberId) {
    _items.remove(_items.firstWhere((element) => element.idl == memberId));
    notifyListeners();
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter:如何正确地将 Provider.of 方法放入 StatefulWidget 中,以便可以在我的代码中使用 Dispose()? - Flutter: How Do I Properly Seat a Provider.of Method into a StatefulWidget so Dispose() Can Be Used in My Code? 如何在Flutter中的单例内部使用Provider.of(...)? - How to use Provider.of(…) inside a singleton in Flutter? 为什么我不能在 build() 中使用 context.read,但我可以使用 Provider.of with listen: false? - Why can't I use context.read in build(), but I can use Provider.of with listen: false? 如何通过Provider.of访问数据 - How to access data through Provider.of 无法使用提供者和获取数据:尝试调用 Provider.of<dynamic></dynamic> - Fail to use Provider and Get Data: Tried to call Provider.of<dynamic> Flutter Provider.of 和搜索 - Flutter Provider.of and search 如何对访问 Provider.of(context) 的小部件进行 Flutter 测试 - How to do a Flutter Test for a widget that accesses Provider.of(context) 如何调用ThemeService themeService = Provider.of(context); 在脚手架的初始状态? - How to call ThemeService themeService = Provider.of(context); in the initial state of a scaffold? 如何访问 showModalBottomSheet 中提供的 (Provider.of()) 值? - How to access Provided (Provider.of()) value inside showModalBottomSheet? ChangeNotifierProvider中Consumer / Provider.of的区别 - Difference Consumer / Provider.of in ChangeNotifierProvider
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM