title: Flutter : How To Convert Future<String> to String?
body: <p>I consume API to fetch Image from database . I have response like this :</p>
  
  <pre><code>{
      "status": "ok",
      "message": "Logo Client Is Found",
      "data": [
          {
              "fileInfo": "img-1.png"
          }
      ]
  }
  </code></pre>
  
  <p>I want get that value from API with this code :</p>
  
  <pre><code> Future&lt;String&gt; getLogoClient() async {
      final response = await _client.get("$_baseUrl/getLogoClient");
      final Map&lt;String, dynamic&gt; responseJson = json.decode(response.body);
      if (responseJson["status"] == "ok") {
        List image = responseJson["data"];
        final imageList =
            image.map((json) =&gt; AppInfoModel.logoFromJson(json)).toList();
        final singleImage = imageList.single.fileInfo;
        final String urlImage = "$baseImageUrl/$singleImage";
        print(urlImage);
        return urlImage;
      } else {
        throw CustomError(responseJson["message"]);
      }
    }
  </code></pre>
  
  <p>Print response :</p>
  
  <pre><code>http://---/images/info/img-1.png
  </code></pre>
  
  <p>The problem is , <strong>i want convert value from Future to String</strong> How can i do this ? </p>
  
  <p>I already trying with this code and success convert that value:</p>
  
  <pre><code>String urlImageApi = "";
    _getImage() async {
      final result = await appInfoApi.getLogoClient();
      setState(() {
        urlImageApi = result;
      });
    }
  
    @override
    void initState() {
      super.initState();
      _getImage();
    }
  </code></pre>
  
  <p>But I get error : </p>
  
  <pre><code>I/flutter ( 8408): #644    ComponentElement.performRebuild 
  package:flutter/…/widgets/framework.dart:4243
  I/flutter ( 8408): #645    Element.rebuild 
  package:flutter/…/widgets/framework.dart:3947
  I/flutter ( 8408): #646    ComponentElement._firstBuild 
  package:flutter/…/widgets/framework.dart:4206
  I/flutter ( 8408): #647    StatefulElement._firstBuild 
  package:flutter/…/widgets/framework.dart:4381
  I/flutter ( 8408): #648    ComponentElement.mount 
  package:flutter/…/widgets/framework.dart:4201
  I/flutter ( 8408): #649    Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  I/flutter ( 8408): #650    Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  I/flutter ( 8408): #651    ComponentElement.performRebuild 
  package:flutter/…/widgets/framework.dart:4243
  I/flutter ( 8408): #652    Element.rebuild 
  package:flutter/…/widgets/framework.dart:3947
  I/flutter ( 8408): #653    ComponentElement._firstBuild 
  package:flutter/…/widgets/framework.dart:4206
  I/flutter ( 8408): #654    ComponentElement.mount 
  package:flutter/…/widgets/framework.dart:4201
  I/flutter ( 8408): #655    Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  I/flutter ( 8408): #656    Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  I/flutter ( 8408): #657    ComponentElement.performRebuild 
  package:flutter/…/widgets/framework.dart:4243
  I/flutter ( 8408): #658    Element.rebuild 
  package:flutter/…/widgets/framework.dart:3947
  I/flutter ( 8408): #659    ComponentElement._firstBuild 
  package:flutter/…/widgets/framework.dart:4206
  I/flutter ( 8408): #660    StatefulElement._firstBuild 
  package:flutter/…/widgets/framework.dart:4381
  I/flutter ( 8408): #661    ComponentElement.mount 
  package:flutter/…/widgets/framework.dart:4201
  I/flutter ( 8408): #662    Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  I/flutter ( 8408): #663    Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  I/flutter ( 8408): #664    ComponentElement.performRebuild 
  package:flutter/…/widgets/framework.dart:4243
  I/flutter ( 8408): #665    Element.rebuild 
  package:flutter/…/widgets/framework.dart:3947
  I/flutter ( 8408): #666    ComponentElement._firstBuild 
  package:flutter/…/widgets/framework.dart:4206
  I/flutter ( 8408): #667    ComponentElement.mount 
  package:flutter/…/widgets/framework.dart:4201
  I/flutter ( 8408): #668    Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  I/flutter ( 8408): #669    Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  I/flutter ( 8408): #670    RenderObjectToWidgetElement._rebuild 
  package:flutter/…/widgets/binding.dart:1028
  I/flutter ( 8408): #671    RenderObjectToWidgetElement.mount 
  package:flutter/…/widgets/binding.dart:999
  I/flutter ( 8408): #672    RenderObjectToWidgetAdapter.attachToRenderTree.&lt;anonymous closure&gt; 
  package:flutter/…/widgets/binding.dart:942
  I/flutter ( 8408): #673    BuildOwner.buildScope 
  package:flutter/…/widgets/framework.dart:2412
  I/flutter ( 8408): #674    RenderObjectToWidgetAdapter.attachToRenderTree 
  package:flutter/…/widgets/binding.dart:941
  I/flutter ( 8408): #675    WidgetsBinding.attachRootWidget 
  package:flutter/…/widgets/binding.dart:819
  I/flutter ( 8408): #676    WidgetsBinding.scheduleAttachRootWidget.&lt;anonymous closure&gt; 
  package:flutter/…/widgets/binding.dart:804
  I/flutter ( 8408): #685    _Timer._runTimers  (dart:isolate-patch/timer_impl.dart:384:19)
  I/flutter ( 8408): #686    _Timer._handleMessage  (dart:isolate-patch/timer_impl.dart:418:5)
  I/flutter ( 8408): #687    _RawReceivePortImpl._handleMessage  (dart:isolate-patch/isolate_patch.dart:174:12)
  I/flutter ( 8408): (elided 11 frames from package dart:async and package dart:async-patch)
  I/flutter ( 8408):
  I/flutter ( 8408): Image provider: NetworkImage("", scale: 1.0)
  I/flutter ( 8408): Image key: NetworkImage("", scale: 1.0)
  I/flutter ( 8408): ════════════════════════════════════════════════════════════════════════════════════════════════════
  </code></pre>
  
  <p>I Miss Something ?</p>