toJson method

Object toJson()

Converts this object to JSON.

Implementation

Object toJson() {
  final Map<String, Object> json = <String, Object>{};

  void addIfPresent(String fieldName, Object? value) {
    if (value != null) {
      json[fieldName] = value;
    }
  }

  addIfPresent('width', width);
  addIfPresent('height', height);
  addIfPresent('data', data);

  return json;
}