title: Flutter, How to use multiple shared preferences
body: <p>My goal was to avoid users getting logged out once they close and reopened the app. So, I used <code>shared_preferences</code> to store the user's email and password locally so, that whenever the user reopens the app I could use firebase's <code>signInWithEmailAndPassword</code> and provide locally stored email and password to it. I used <code>setString()</code> to store email password but I was able to store only email and not the password, I get the error &quot;Password is null&quot; How do I solve this. Did I do the code right?</p>
  <p>Storing email and password when user registers in app</p>
  <pre><code>onPressed: () async {
                    try {
                      final user =
                          await _auth.createUserWithEmailAndPassword(
                              email: email, password: password);
                      if (user != null) {
                        final SharedPreferences sharedPreferences =
                            await SharedPreferences.getInstance();
                        sharedPreferences.setString(
                          'email',
                          email,
                        );
                        sharedPreferences.setString('password', password);
                        Get.to(() =&gt; const BorrowerList());
                      }
                    } catch (e) {
                      Get.snackbar('Error', e.toString(),
                          backgroundColor: (Colors.red));
                    }
                  },
  </code></pre>
  <p>fetching email password and login after reopening.</p>
  <pre><code>  @override
    void initState() {
      super.initState();
      validateUserAuth();
    }
  
    final _firestore = FirebaseFirestore.instance;
    void validateUserAuth() async {
      final SharedPreferences sharedPreferences =
          await SharedPreferences.getInstance();
      var obtainedEmail = sharedPreferences.getString('email');
      var obtainedPassword = sharedPreferences.getString('password');
      if (obtainedEmail != null || obtainedPassword != null) {
        setState(() {
          loggedinUserEmail = obtainedEmail!;
          loggedinUserPassword = obtainedPassword!;
        });
        if (loggedinUserEmail != null || loggedinUserPassword != null) {
          final loggedinuser = await auth.signInWithEmailAndPassword(
              email: loggedinUserEmail, password: obtainedPassword!);
          if (loggedinuser != null) {
            Get.to(() =&gt; const BorrowerList());
          }
        }
      } else {
        Get.to(() =&gt; AuthScreen());
      }
    }
  </code></pre>