set method

  1. @override
Future<void> set(
  1. String path,
  2. Uint8List buffer
)
override

Writes a byte array data to a specific path.

If the path or its parent directories do not exist, they should be created.

Implementation

@override
Future<void> set(String path, Uint8List buffer) async {
  path = path.replaceFirst(
    '{document}',
    await getApplicationDocumentsDirectory().then((value) => value.path),
  );

  final dir = dirname(path);
  final directory = Directory(dir);

  // Ensure the directory exists before writing the file.
  await directory.create(recursive: true);

  await File(path).writeAsBytes(buffer);
}