toJson method

  1. @override
Map<String, Object> toJson()
override

Serializes this resource to a JSON-encodable map.

Returns:

  • A map containing all relevant resource metadata
  • Should include at minimum a 'type' field identifying the resource kind
  • Must contain only JSON-encodable values

Implementation Requirements:

  • Must be overridden by subclasses
  • Should include all identifying metadata
  • Should maintain backward compatibility

Example Output:

{
  "type": "font",
  "family": "Roboto",
  "files": ["Roboto-Regular.ttf", "Roboto-Bold.ttf"]
}

Implementation

@override
Map<String, Object> toJson() {
  Map<String, Object> result = {};
  result['filePath'] = _filePath;
  result['fileName'] = _fileName;
  result['packageName'] = _packageName;
  result['contentBytes'] = _contentBytes.toString();
  return result;
}