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 className0 = className?.trim().nullIfEmpty;
    final fields0 = fields
        ?.map(
          (p0) => p0,
        )
        .nonNulls
        .nullIfEmpty
        ?.toList();
    final shouldInherit0 = shouldInherit;
    final inheritanceConstructor0 =
        inheritanceConstructor?.trim().nullIfEmpty;
    final keyStringCase0 = keyStringCase?.trim().nullIfEmpty;
    final description0 = description?.trim().nullIfEmpty;
    final withNulls = {
      'shouldInherit': shouldInherit0,
      'keyStringCase': keyStringCase0,
      'inheritanceConstructor': inheritanceConstructor0,
      'fields': fields0,
      'description': description0,
      'className': className0,
    };
    return includeNulls ? withNulls : withNulls.nonNulls;
  } catch (e) {
    assert(false, '$GenerateDartModel.toJson: $e');
    rethrow;
  }
}