title: How to implement Flutter Riverpod FutureProvider with shared_preferences library?
body: <p>My current implementation without FutureProvider + shared_preferences:</p>
  <pre><code>class IdentityModel {
    final bool isLoggedIn;
    final int id;
    final String userName;
    final String avatarUrl;
  
    const IdentityModel({
      this.isLoggedIn = false,
      this.id,
      this.userName,
      this.avatarUrl,
    });
  }
  
  class IdentityNotifier extends StateNotifier&lt;IdentityModel&gt; {
    IdentityNotifier() : super(_initialState);
  
    static final _initialState = IdentityModel();
  
    void loginAction(MyCustomUserClass user) {
      state = IdentityModel(
        isLoggedIn: true,
        id: user.id,
        userName: user.userName,
        avatarUrl: user.avatarUrl,
      );
    }
  
    void logoutAction() {
      state = IdentityModel(
        isLoggedIn: false,
        id: null,
        userName: null,
        avatarUrl: null,
      );
    }
  }
  
  final identityProvider = StateNotifierProvider&lt;IdentityNotifier&gt;(
    (ref) =&gt; IdentityNotifier(),
  );
  </code></pre>
  <p>I want to persist state using the <code>shared_preferences</code> package, but I'm not quite sure how to convert my current implementation to one that uses <code>FutureProvider</code> as <code>shared_preferences</code> uses <code>async/await</code> to get/set.</p>
  <p>I basically want to &quot;load&quot; from <code>shared_preferences</code> using it's <code>get</code> methods to initialize the notifier when the app starts up and then call <code>shared_preferences</code> <code>set</code> methods in the notifier methods <code>loginAction</code> and <code>logoutAction</code>.</p>