get method

  1. @override
Future<Uint8List> get(
  1. String path
)
override

Reads and returns the data from a path as a Uint8List.

If the file does not exist, an empty Uint8List should be returned.

Implementation

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

  final dir = Directory(dirname(path));
  if (!await dir.exists()) return Uint8List(0);

  final file = File(path);
  if (!await file.exists()) return Uint8List(0);

  return file.readAsBytes();
}