title: Get text from ".txt" file and save it in String variable dart
body: <p>I have a ".txt" file called "bio.txt" inside the Document folder of my application.
  I want to read its content and store it inside a String variable.
  My problem is that the "reading action" is a "Future" function and I have some troubles to save its value in a "String".</p>
  
  <p>I read the file with :</p>
  
  <pre class="lang-dart prettyprint-override"><code>Future&lt;String&gt; get _localPath async {
    final directory = await getApplicationDocumentsDirectory();
    return directory.path;
  }
  
  Future&lt;File&gt; _localFile(String name) async {
    final path = await _localPath;
    return File('$path/$name');
  }
  
  Future&lt;String&gt; _read(String filename) async {
    try {
      final file = await _localFile(filename);
  
      // Read the file.
      return await file.readAsString();
    } catch (e) {
      // If encountering an error, return 0.
      return "Can't read";
    }
  }
  </code></pre>
  
  <p>And I would like to save it with :</p>
  
  <pre class="lang-dart prettyprint-override"><code>String _bio = _read("bio.txt").then((value) =&gt; String);
  </code></pre>
  
  <p>Do you know why this solution isn't working?
  Any suggestion?</p>