createImage method
Creates and returns a local image
File according to the given name
and imagePath
.
Implementation
Future<File> createImage(String name, String imagePath) async {
final directory = await getApplicationDocumentsDirectory();
final file = File('${directory.path}/$name');
final imageData = await rootBundle.load(imagePath);
final bytes = imageData.buffer
.asUint8List(imageData.offsetInBytes, imageData.lengthInBytes);
file.writeAsBytesSync(bytes);
return file;
}