【问题标题】:Flutter | How to store List of List<String> in Shared Preferences?颤振 |如何在共享首选项中存储 List<String> 的列表?
【发布时间】:2021-08-24 10:39:39
【问题描述】:

我正在尝试使用 Flutter 的共享首选项插件将字符串列表保存在列表中。

[
  ["str1", "str2"],
  ["str3", "str4"]
]

【问题讨论】:

  • 欢迎来到 SO - 请描述您的问题...

标签: android flutter dart


【解决方案1】:

试试这个:

const temp = json.encode({'data':[
  ["str1", "str2"],
  ["str3", "str4"]
]});

然后将temp 保存在您的共享首选项中。从您的 sharedPref 获取此字符串后,不要忘记使用 json.decode。

【讨论】:

    猜你喜欢
    • 2020-05-29
    • 2021-08-16
    • 2020-04-02
    • 1970-01-01
    • 1970-01-01
    • 2021-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多