saveFile method
void
saveFile()
Save the current content, controller.text to the opened file.
Implementation
void saveFile() {
if (kIsWasm || kIsWeb) {
throw PlatformException(
code: 'unsupported',
message: 'This method is not supported on the web.',
);
}
if (openedFile == null) {
throw FlutterError(
"No file found.\nPlease open a file by providing a valid filePath to the CodeForge widget",
);
}
final file = File(openedFile!);
if (!file.existsSync()) {
throw FlutterError(
"No file found.\nPlease open a file by providing a valid filePath to the CodeForge widget",
);
}
file.writeAsStringSync(text);
}