title: Convert Image from Buffer to display in Frontend (Flutter)
body: <p>I have a backend based on NodeJS and using mongodb as the database. Images with the field name photo is saved as object Type Buffer. I have successfully sent Images from the app using form data but I am not able to display the image in frontend.</p>
  <p>This is the function used to get the data from API</p>
  <pre><code>Future&lt;User&gt; userWithId() async {
    User result;
     try {
        final response = await http.get(
          'api link',
          headers: &lt;String, String&gt;{
            'Authorization': 'Bearer $token',
          },
        );
        if (response.statusCode == 200) {
          result = User.fromJson(jsonDecode(response.body));
        }
     } catch (e) {
        print(e.toString());
     }
    return result;
  }
  </code></pre>
  <p>This is the fromJson function of the class User. The photo field here returns the image as buffer.</p>
  <pre><code>factory User.fromJson(Map&lt;String, dynamic&gt; json) {
    return User(
      id: json['_id'] as String ?? &quot;&quot;,
      email: json['email'] as String ?? &quot;&quot;,
      // profilePhoto: json[&quot;photo&quot;] ?? null,
      // profilePhoto: base64.encode(jsonDecode(json[&quot;photo&quot;])) ?? null,
    );
  }
  </code></pre>
  <p>This is the data from the photo field
  <a href="https://i.stack.imgur.com/Eha31.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Eha31.png" alt="enter image description here" /></a></p>
  <p>This is the data from MongoDB database
  <a href="https://i.stack.imgur.com/NGfqN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NGfqN.png" alt="enter image description here" /></a></p>