toJson method Null safety

Map toJson()

Implementation

Map toJson(){
  Map result = {};

  if (length != null) result.addAll({"length": length});
  if (data != null) result.addAll({"data": data});

  return result;
}