Ali F. Abbas
Ali F. Abbas

Reputation: 61

Flutter | How to store List of List<String> in Shared Preferences?

I'm trying to use flutter's shared preferences plugin to save a lists of strings inside a list.

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

Upvotes: 0

Views: 195

Answers (1)

Abbasihsn
Abbasihsn

Reputation: 2171

try this:

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

then save temp in your sharedpref. Do not to forget to use json.decode after getting this string from your sharedPref.

Upvotes: 2

Related Questions