getFileSync method

  1. @override
ItemOutput getFileSync(
  1. String filePath
)
override

Reads an item from the specified path synchronously.

Throws an Exception if the file doesn't exist or cannot be read.

Implementation

@override
ItemOutput getFileSync(String filePath) {
  final fullPath = _resolvePath(filePath);
  final file = File(fullPath);
  if (!file.existsSync()) {
    throw Exception('File does not exist: $filePath');
  }
  final data = file.readAsStringSync();
  final item = json.decode(data) as Map<String, dynamic>;
  final stat = file.statSync();
  return ItemOutput(item: item, createdAt: stat.modified.toIso8601String());
}