Read image file from iOS local storage and display in an image widget?

Widgets & Design

Is this possible?

Using local run and custom action I have saved an image to the iOS Files app folder and stored its location in a Firestore collection field. The saved file location is this:

/var/mobile/Containers/Data/Application/9086D1AB-085A-4789-A9F9-8286C1DC0EB3/Documents/Images/testimg.png

I have another custom action to read it from this location and pass it as as an imagePath to an image widget but it will not display. It gives an error like 'no host specified in URI file:///var/mobile etc.'

I also noted the string between Application and Documents changes between test runs when run in local run mode.

What have you tried so far?

I have tried using the whole image path from the Firebase collection field which didn't work and also when reading the file and also by using the following code by just including the name of the file as an input string.

import 'dart:io';
import 'package:path_provider/path_provider.dart';

Future<String> readFromFolder(String shortname) async {

  shortname = shortname + '.png';

  // Get the directory for the app's documents
  Directory appDocDir = await getApplicationDocumentsDirectory();

  // Construct the full path to the image file
  String filePath = '${appDocDir.path}/images/$shortname)';

  // Check if the file exists
  if (await File(filePath).exists()) {
    // Read the file and return its contents
    return await File(filePath).readAsString();
  } else {
    throw Exception('File not found');
  }
}

but it is giving a File not found message

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