save method
Save content to a memory file.
Implementation
Future<MemoryFile> save(String path, String content) async {
final file = File(path);
await file.parent.create(recursive: true);
await file.writeAsString(content);
final stat = await file.stat();
final hash = _hashContent(content);
final memFile = MemoryFile(
path: path,
type: _inferType(path),
content: content,
lastModified: stat.modified,
hash: hash,
version: (_files[path]?.version ?? 0) + 1,
);
_files[path] = memFile;
_lastKnownHashes[path] = hash;
_eventController.add(MemoryFileChanged(memFile));
return memFile;
}