I propose you a small tutorial that will allow you to delete an image file when it has been uploaded in Firebase Storage.
As you know and until today, there is no way on FlutterFlow to delete a file (image, video, ...) when it has been uploaded on Firebase by a user.
So we will create a Custom Action code.
1- Go to Custom Action
2- Click on "+ Create"
3- Give a name to your code, I chose "deleteImage".
4- [OPTIONAL] Activate "Return value" if you want to have a return in case of error. In "Data Type", select "String".
5- In "Define Arguments", click on "+ Add Parameter" then give an "argument name" for example "urlImage" and select the "Data Type" in our case here "ImagePath"
6- Click on "+ Add Dependency" then enter "firebase_storage".
7- On the right side, enter the following code:
import 'package:firebase_storage/firebase_storage.dart';
Future<String> deleteImage(String urlFile) async {
String error;
try {
await FirebaseStorage.instance.refFromURL(urlFile).delete();
}
catch(e){
error = e;
}
return error;
}
You should have this screen :
8- Finish by pressing "Check errors", after a few seconds you should get a green button "No Errors!".
You can now use this code in your actions.
I hope you will find it useful.
Don't hesitate to ask me questions.
Damien