writeUint8ListtoTemporaryDirectory method

Future<File?> writeUint8ListtoTemporaryDirectory({
  1. Uint8List? data,
  2. String? extension = "",
})

This used to write Byte data to file like image is compress or download it will

Implementation

Future<File?> writeUint8ListtoTemporaryDirectory(
    {Uint8List? data, String? extension = ""}) async {
  if (data == null) return null;
  Directory tempDir = await pp.getTemporaryDirectory();
  String tempPath = tempDir.path;
  String uuid = Uuid().v4();
  var filePath = tempPath + '/${uuid}.${extension}';
  return new File(filePath).writeAsBytes(data);
}