I have a Future which is called when user trys to login:

Future<String> login(String phone, String password) async {

    _firebaseMessaging.getToken().then((fmctoken) => print(fmctoken));

    Response response = await _dio.post(loginUrl, data: {
      "login": phone,
      "password": password,
    return response.data["objectId"];


In this Future i also get the fmc_device_token, which I want to upload to other rest_api_url. The problem is, that i need this: return response.data["objectId"]; the objectId to upload the data.

How can I make, that if this Future is called and the objectId received, the value of the fmctoken_device will upload (post) on other url.

Thanks for your help!!!

Solution 1: griffins

In your other function where you need response.data["objectId"]; to upload data you can call the login function and await for its response, then do your updates

Future<dynamic> myotherFunction(String phone, String password)async{
var response= await login(phone,password);
//heere  you have your `objectId`