toJson method

  1. @override
Map<String, dynamic> toJson({
  1. bool includeNulls = false,
})
override

Returns a Json i.e. Map<String, dynamic> representation of the BaseModel.

Implementation

@override
Map<String, dynamic> toJson({
  bool includeNulls = false,
}) {
  try {
    final id0 = id?.trim().nullIfEmpty;
    final ref0 = ref?.toJson();
    final withNulls = {
      'ref': ref0,
      'id': id0,
    };
    return includeNulls ? withNulls : withNulls.nonNulls;
  } catch (e) {
    assert(false, '$ReferencedModel.toJson: $e');
    rethrow;
  }
}