openFile property
set
openFile
(String? file)
Open a file using the controller API instead of passing filePath parameter to CodeForge.
Implementation
set openFile(String? file) {
if (file != null && (kIsWeb || kIsWasm)) {
throw UnsupportedError(
'CodeForgeController.openFile is not supported on web. Use fileUrl or fileUri instead.',
);
}
final previousFile = _openedFile;
_openedFile = file;
if (openedFile != null) {
if (!(kIsWeb || kIsWasm) && fileUrl == null) {
text = File(_openedFile!).readAsStringSync();
}
}
if (previousFile != openedFile &&
lspConfig != null &&
lspConfig!.isInitialized &&
openedFile != null) {
(() async {
await _openDocumentInLsp(previousFile: previousFile);
})();
}
}