I am trying to save image upload from the camera or gallery permanently, I am using the image_picker
package, and each time I choose a picture for a pfp and click on a different tab it's gone, it only saves it temporarily.
this is my code below:
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:path_provider/path_provider.dart';
// camera
Future getCameraImage() async{
// getting the image
final image = await ImagePicker().pickImage(source: ImageSource.camera);
if(image == null) return;
// final imageTemporary = File(image.path);
final imagePerm = await saveImagePermanently(image.path);
setState(() {
this.image = imagePerm;
});
}
// image picker/ gallery
File? image;
Future getImage() async{
final image = await ImagePicker().pickImage(source: ImageSource.gallery);
if(image == null) return;
final imageTemporary = File(image.path);
setState(() {
this.image = imageTemporary;
});
}
I have tried a few different methods but run into the same error.