I have a base64 string of an image, and I want to make a method to convert that to a Flutter Image
.
There is an existing SO question asking exactly that, however all of the answers there make use of the Image.memory
constructor for the Image
, and when I go to do that I get the following error:
The method 'memory' isn't defined for the type 'Image'. Try correcting the name to the name of an existing method, or defining a method named 'memory'.
Searching for "The method 'memory' isn't defined for the type 'Image'." on Google gives 0 results.
There is definitely an Image.memory
constructor: https://api.flutter.dev/flutter/widgets/Image/Image.memory.html
This is my code: return Image.memory(base64Decode(base64DataString));
I am certain I'm just having a blond moment here, but I am stumped and asking for help nonetheless.
Why am I getting this error when trying to call Image.memory
?
When you encounter errors like this, you're almost certainly unwittingly using a different class than the one you think but that happens to have the same name.
Your IDE should be able to tell you where the definition for the Image
class is coming from. It's not the one from the Flutter Widgets library.