writeFileAsString method
Writes contents to the file at uri in the environment where the Dart
Tooling Daemon is running.
The file will be created if it does not exist, and it will be overwritten if it already exist.
If uri is not contained in the IDE workspace roots, then an
RpcException with RpcErrorCodes.kPermissionDenied is thrown.
If uri does not have a file scheme, then an RpcException with
RpcErrorCodes.kExpectsUriParamWithFileScheme is thrown.
Implementation
Future<void> writeFileAsString(
Uri uri,
String contents, {
Encoding encoding = utf8,
}) async {
await call(
FileSystemServiceConstants.serviceName,
FileSystemServiceConstants.writeFileAsString,
params: {
DtdParameters.uri: uri.toString(),
DtdParameters.contents: contents,
DtdParameters.encoding: encoding.name,
},
);
}