readFileAsString method

Future<FileContent> readFileAsString(
  1. Uri uri, {
  2. String encoding = 'utf8',
})

Reads the file at uri from disk and returns the content as a String.

If there are unsaved changes to the file at uri, for example from an IDE, those will be ignored.

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

Implementation

Future<FileContent> readFileAsString(
  Uri uri, {
  String encoding = 'utf8',
}) async {
  final result = await call(
    DTDFileService.serviceName,
    FileSystemServiceMethods.readFileAsString.name,
    params: {
      'uri': uri.toString(),
      'encoding': encoding,
    },
  );
  return FileContent.fromDTDResponse(result);
}