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 collection0 = collection
        ?.map(
          (p0) => p0?.trim().nullIfEmpty,
        )
        .nonNulls
        .nullIfEmpty
        ?.toList();
    final withNulls = {
      'id': id0,
      'collection': collection0,
    };
    return includeNulls ? withNulls : withNulls.nonNulls;
  } catch (e) {
    assert(false, '$DataRefModel.toJson: $e');
    rethrow;
  }
}