title: Flutter: Could not instantiate image codec when calling Image.memory
body: <p>I want to create a simple profile picture for my app.
  I thought it would work like this, but it throws an exception when calling it and I
  can't figure out why.</p>
  
  <pre><code>Widget _buildProfilePicture(double size) {
        if (user.profileImage != null) {
          return ClipRRect(
            borderRadius: BorderRadius.circular(8.0),
            child: Image.memory(
              user.profileImage,
              width: size,
              height: size,
            ),
          );
        }
  }
  </code></pre>
  
  <p>The attribute <code>user.profileImage</code> has the datatype <code>Uint8List</code>.</p>
  
  <p>When I call it, it throws this exception:</p>
  
  <pre><code>════════ Exception caught by image resource service ════════════════════════════════════════════════
  The following _Exception was thrown while resolving an image:
  Exception: Could not instantiate image codec.
  
  When the exception was thrown, this was the stack: 
  #0      _futurize (dart:ui/painting.dart:4304:5)
  #1      instantiateImageCodec (dart:ui/painting.dart:1682:10)
  #2      PaintingBinding.instantiateImageCodec (package:flutter/src/painting/binding.dart:88:12)
  #3      MemoryImage._loadAsync (package:flutter/src/painting/image_provider.dart:714:18)
  #4      MemoryImage.load (package:flutter/src/painting/image_provider.dart:706:14)
  ...
  Image provider: MemoryImage(Uint8List#2592a, scale: 1.0)
  Image configuration: ImageConfiguration(bundle: PlatformAssetBundle#633d8(), devicePixelRatio: 2.6, locale: en_US, textDirection: TextDirection.ltr, size: Size(50.0, 50.0), platform: android)
  Image key: MemoryImage(Uint8List#2592a, scale: 1.0)
  </code></pre>
  
  <p>I think it's caused by <code>Image.memory</code>.</p>
  
  <p>Thanks for answers in advance!</p>