【问题标题】:How to add "add to favorite" button or icon in detail, that will be add in "favorite" page in flutter如何详细添加“添加到收藏”按钮或图标,将添加到 Flutter 中的“收藏”页面
【发布时间】:2020-07-14 00:30:09
【问题描述】:

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

【问题讨论】:

    标签: flutter flutter-layout flutter-dependencies


    【解决方案1】:

    如果你想在本地存储一些东西,你可以尝试使用 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-14
      • 2019-05-16
      • 2019-08-19
      • 1970-01-01
      • 1970-01-01
      • 2012-04-19
      • 2020-11-08
      相关资源
      最近更新 更多