title: Flutter how to save each key value receive from rest API to different shared preference value be it string or int
body: <p>Can anyone help with how I can get these this array of objects saved in shared preferences with flutter? I created a JSON rest API that returns the below array of an object:</p>
  <pre><code>[{
      &quot;first_name&quot;: &quot;firstname&quot;,
      &quot;last_name&quot;: &quot;lastname&quot;,
      &quot;profile_pic&quot;: &quot;user.png&quot;,
      &quot;designation_id&quot;: &quot;33&quot;,
      &quot;department_id&quot;: &quot;2&quot;,
      &quot;employee_id&quot;: &quot;175&quot;,
      &quot;level&quot;: &quot;hr&quot;,
      &quot;dept_code&quot;: &quot;HR&quot;,
      &quot;email&quot;: &quot;email.com&quot;,
      &quot;user_id&quot;: &quot;1&quot;
  }]
  </code></pre>
  <p>Am looking for a workaround on how to save each key value to a shared preference and reuse it.
  For example save <code>&quot;first_name&quot;, &quot;last_name&quot;...</code> below is how am receiving my JSON:</p>
  <pre><code>
  final String baseUrl = &quot;http://xxx/login.php&quot;;
      var response;
      Client client = Client();
  
  Future&lt;bool&gt; createProfile(LoginProfile data) async {
        response = await client.post(
          &quot;$baseUrl&quot;,
          headers: {&quot;content-type&quot;: &quot;application/json&quot;},
          body: loginProfileToJson(data),
        );
  
      }
  
  var resBody = json.decode(response.body); 
  String array = resBody.toString(); 
  SharedPreferences prefs = await SharedPreferences.getInstance(); 
  prefs.setString('array', array);
  
  </code></pre>
  <p>With the above, it is not receiving the value separately but together and I want to have each value saved individually to reuse for example:</p>
  <pre><code>prefs.setString('firstname', first_name);
  prefs.setString('lastname', last_name);
  prefs.setString('level', level);
  prefs.setString('deptcode', dept_code)... and so on.
  </code></pre>