I have tried several ways, but I'm new to flutter and mobile development so I'm not quite conversant with the whole environment.
I used the painter example here https://pub.dev/packages/painter/example
I used this code to try to save the image file.
image_file.dart
import 'dart:ui';
class ImageFile {
var imageFile;
get getImageFile => this.imageFile;
set setImageFile(var imageFile) => this.imageFile = imageFile;
ImageFile({required this.imageFile});
}
then I created the instance of the class and assigned the
Image.memory(snapshot.data)
as
ImageFile(imageFile: Image.memory(snapshot.data!));
to it so that I can access it globally and then I created a method to save the image from the ImageFile object and attached it to a floatingActionButton.
void _saveFileImage(path) async {
String path = (await getApplicationDocumentsDirectory()).path;
GallerySaver.saveImage(path);
}
floatingActionButton: FloatingActionButton(
onPressed: () {
if (imageFile!.getImageFile != null) {
_saveFileImage(imageFile!.getImageFile);
} else {
debugPrint("null object");
}
}, //_saveImage(imageFile),
tooltip: 'Save to gallery',
child: const Icon(Icons.save_alt_outlined),
),
Please if you have any idea on how to use the gallery_saver package or the image_gallery_saver package in the painter package kindly help out.
image_file.dart - https://codeshare.io/Pdm0lY
main.dart - https://codeshare.io/78gMbL
Thanks