devToolsFileAsJson static method

String? devToolsFileAsJson(
  1. String pathFromDevToolsDir
)

Returns a DevTools file from the given path as encoded json.

Only files within ~/.flutter-devtools/ can be accessed.

Implementation

static String? devToolsFileAsJson(String pathFromDevToolsDir) {
  final file = devToolsFileFromPath(pathFromDevToolsDir);
  if (file == null) return null;

  final fileName = path.basename(file.path);
  if (!fileName.endsWith('.json')) return null;

  final content = file.readAsStringSync();
  final json = jsonDecode(content) as Map;
  json['lastModifiedTime'] = file.lastModifiedSync().toString();
  return jsonEncode(json);
}