process method

  1. @override
Future<Map<String, dynamic>> process()
override

Internal method used by dash_agent to convert the shared DataSource to json format that can be sent on the web

Note: Ideally, this method is not supposed to be overriden by the child objects and should not be altered. It is called automatically by the framework.

Implementation

@override
Future<Map<String, dynamic>> process() async {
  if (!file.existsSync()) {
    throw Exception('File does not exist');
  }

  return {
    'id': hashCode.toString(),
    'type': 'file_object',
    'content': await file.readAsString(),
    ...(includePath ? {'path': p.relative(file.path, from: relativeTo)} : {}),
    'version': minCliVersion
  };
}