writeFileAsString method

Future<bool> writeFileAsString(
  1. Uri uri,
  2. String contents, {
  3. Encoding encoding = utf8,
})

Writes contents to the file at uri.

The file will be created if it does not exist, and it will be overwritten if it already does exist.

If there are unsaved changes to the file at uri, for example from an IDE, those will be ignored and the IDE will handle any conflicts that occur from writing the file on disk.

The return value can be one of {'type': 'Success'} or an RpcException.

Implementation

Future<bool> writeFileAsString(
  Uri uri,
  String contents, {
  Encoding encoding = utf8,
}) async {
  final response = await call(
    DTDFileService.serviceName,
    FileSystemServiceMethods.writeFileAsString.name,
    params: {
      'uri': uri.toString(),
      'contents': contents,
      'encoding': encoding.name,
    },
  );
  return response.result['result'] == true;
}