Problem loading local images in FlutterFlow

Custom Code

I'm trying to load a local image in FlutterFlow from project assets. The image has been correctly uploaded to the project's Assets section (I can see it at URL https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/memory-trainer-h8ppeq/assets/zxb9wbmrx50q/king_of_spades2.png).

I have enabled "download unused project assets" in the project settings.

My goal is to display random images from my local assets.

I tried with this custom function:

String getAssetImage() { return "assets/king_of_spades2.png"; }

or

String getAssetImage() { return "king_of_spades2.png"; }

But I get this error:

โ•โ•โ•ก EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE โ•žโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• The following Event object was thrown resolving an image frame: [object Event] When the exception was thrown, this was the stack Image provider: NetworkImage("", scale: 1.0) Image key: NetworkImage("", scale: 1.0) โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

How can I properly load the image from local assets instead of the remote URL?

What have you tried so far?

I tried with this custom function:

String getAssetImage() { return "assets/king_of_spades2.png"; }

or

String getAssetImage() { return "king_of_spades2.png"; }

Did you check FlutterFlow's Documentation for this topic?
Yes
1
3 replies