capture method

String? capture(
  1. String path, {
  2. bool optional = false,
})

Implementation

String? capture(String path, {bool optional = false}) {
  if (contains(path)) return _originals[path];
  final file = File(path);
  if (!file.existsSync()) {
    if (!optional) throw StateError('Expected file not found: $path');
    _originals[path] = null;
    return null;
  }
  final contents = file.readAsStringSync();
  _originals[path] = contents;
  return contents;
}