title: Flutter : Prevent Drawer Always Refresh at Swipe inside FutureBuilder
body: <p><img src="https://i.stack.imgur.com/JyNlM.gif" height="500"></p>
  
  <p>I have a problem make me annoying about the drawer. I have Drawer inside FutureBuilder for fetching user profiles from API. The problem is every I swipe/open the drawer, it will refresh before fetching the user profile. It makes a bad user experience.</p>
  
  <p>I already searching how to make FutureBuilder run once only from <a href="https://stackoverflow.com/a/57793517/7360353">this</a> , But the drawer still refreshes.
  <p> I missed something? </p>
  
  <h1>Drawer Custom</h1>
  
  <pre><code>class _DrysDrawerCustomState extends State&lt;DrysDrawerCustom&gt; {
    Future&lt;List&lt;UserModel&gt;&gt; userList;
  
    @override
    void didChangeDependencies() {
      super.didChangeDependencies();
      final username = Provider.of&lt;GlobalProvider&gt;(context).username;
      userList = userApi.getUserByUsername(username: username);
    }
  
    @override
    Widget build(BuildContext context) {
      final globalProvider = Provider.of&lt;GlobalProvider&gt;(context, listen: false);
      //TODO Change Structure Drawer
      return FutureBuilder(
        future: userList,
        builder: (BuildContext context, AsyncSnapshot&lt;List&lt;UserModel&gt;&gt; snapshot) {
          if (snapshot.connectionState == ConnectionState.done) {
            if (snapshot.hasError) {
              return ErrorFutureBuilder(errorText: snapshot.error);
            } else {
              final user = snapshot.data[0];
              return DrawerCustom(
                imageUrl: "${userApi.baseImageUrl}/${user.fotoUser}",
                detailUser: [
                  Text(user.namaUser),
                  Text(user.namaGroup),
                ],
                drawerMenu: [
                  DrawerMenu(
                    menuName: "Profil Info",
                    icon: Icons.people_outline,
                    onTap: () =&gt; Navigator.of(context)
                        .pushNamed(ProfilInfoScreen.routeNamed),
                  ),
                  DrawerMenu(
                    menuName: "Ganti Password",
                    icon: Icons.lock,
                    onTap: () =&gt; Navigator.of(context)
                        .pushNamed(ChangePasswordScreen.routeNamed),
                  ),
                  Divider(),
                  DrawerMenu(
                    menuName: "Logout",
                    icon: Icons.arrow_back,
                    onTap: () {
                      globalProvider.removeUsername();
                      Navigator.of(context)
                          .pushReplacementNamed(LoginScreen.routeNamed);
                    },
                  ),
                ],
              );
            }
          } else {
            return LoadingFutureBuilder();
          }
        },
      );
    }
  }
  
  </code></pre>
  
  <h1>Global Provider</h1>
  
  <pre><code>GlobalProvider() {
      _initialSharedPreferences();
    }
  String _username;
    String get username =&gt; _username;
  
    void _initialSharedPreferences() async {
      await getUsername();
    }
  
    Future updateUsername(String username) async {
      SharedPreferences pref = await SharedPreferences.getInstance();
      await pref.setString("username", username);
      //! It's Important !!! After update / remove sharedpreferences  , must called getUsername() to updated the value.
      await getUsername();
      notifyListeners();
    }
  
    Future removeUsername() async {
      SharedPreferences pref = await SharedPreferences.getInstance();
      final result = await pref.remove("username");
      //! It's Important !!! After update / remove sharedpreferences  , must called getUsername() to updated the value.
      await getUsername();
      notifyListeners();
      return result;
    }
  
    Future getUsername() async {
      SharedPreferences pref = await SharedPreferences.getInstance();
      final result = pref.getString("username");
      _username = result;
      notifyListeners();
    }
  </code></pre>