'update UI appdrawer using id token claim

I'm using custom claim to control access to my app and update UI according to that what I want to do is after login i want to update my appdrawer based on the claim of the user that loged in (admin,..) i used this method to get the token and check if it's admin or not ...it worked fine but there is always time delay untill i get back a boolean reslut of isAdmin and that causes my appdrawer to remain empty till i press hot reload in android studio

    Future<Map<dynamic, dynamic>> get currentUserClaims async {
    final user = FirebaseAuth.instance.currentUser;
    // If refresh is set to true, a refresh of the id token is forced.
    final idTokenResult = await user.getIdTokenResult(true);
    return idTokenResult.claims;
  }

  Future<bool> updateUI(BuildContext context) async {
     isAdmin = ( await currentUserClaims)['admin'] == true;

    if(isAdmin){
      _visible_for_all =  true;
    }
    else {
      _visible_for_user1 =  true;
      _visible_sign_out =  true;
    }
  }

  @override
  void initState() {
    super.initState();
 
    updateUI(context);
  }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source