uint8ListToXFile method

Future<XFile> uint8ListToXFile({
  1. required Uint8List bytes,
  2. String fileName = 'history_detail.png',
})

Implementation

Future<XFile> uint8ListToXFile(
    {required Uint8List bytes,
      String fileName = 'history_detail.png'}) async {
  final tempDir = await getTemporaryDirectory();
  final file = await File('${tempDir.path}/$fileName').create();
  await file.writeAsBytes(bytes);
  return XFile(file.path);
}