writeToFile function

Future<File> writeToFile(
  1. ByteData data,
  2. String file
)

Implementation

Future<File> writeToFile(ByteData data, String file) async {
  final buffer = data.buffer;
  Directory? tempDir = await getExternalStorageDirectory();
  String? tempPath = tempDir?.path;
  var filePath =
      tempPath! + '/' + file; // file_01.tmp is dump file, can be anything
  return new File(filePath)
      .writeAsBytes(buffer.asUint8List(data.offsetInBytes, data.lengthInBytes));
}