如何详细添加“添加到收藏夹”按钮或图标,将在flutter的“收藏夹”页面中添加

时间:2020-07-14 00:30:09

标签: flutter flutter-layout flutter-dependencies

我有一个包含某些元素的GirdView,每个元素都有其自己的详细信息页面,我想详细添加按钮或图标以将其本地和永久保存在“收藏夹”页面中,以便用户以后可以找到它们采用。 是否有任何相关文档或教程?

1 个答案:

答案 0 :(得分:0)

如果要在本地存储内容,可以尝试使用shared_preferences pub.dev。使用示例很简单:

_incrementCounter() async {
  SharedPreferences prefs = await SharedPreferences.getInstance();
  int counter = (prefs.getInt('counter') ?? 0) + 1;
  print('Pressed $counter times.');
  await prefs.setInt('counter', counter);
}

有关更多信息,请访问medium guide