writeBytes function

Future<File> writeBytes(
  1. File file,
  2. Uint8List bytes
)

Write bytes content. Does not fail

Implementation

Future<File> writeBytes(File file, Uint8List bytes) async {
  try {
    await file.writeAsBytes(bytes, flush: true);
  } catch (_) {
    await file.create(recursive: true);
    await file.writeAsBytes(bytes, flush: true);
  }
  return file;
}