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 fieldPath0 = fieldPath
        ?.map(
          (p0) => p0?.trim().nullIfEmpty,
        )
        .nonNulls
        .nullIfEmpty
        ?.toList();
    final fieldType0 = fieldType;
    final nullable0 = nullable;
    final children0 = children
        ?.map(
          (p0) => p0
              ?.map(
                (p0, p1) => MapEntry(
                  p0?.trim().nullIfEmpty,
                  p1,
                ),
              )
              .nonNulls
              .nullIfEmpty,
        )
        .nonNulls
        .nullIfEmpty
        ?.toList();
    final primaryKey0 = primaryKey;
    final foreignKey0 = foreignKey;
    final fallback0 = fallback;
    final description0 = description?.trim().nullIfEmpty;
    final withNulls = {
      'primaryKey': primaryKey0,
      'nullable': nullable0,
      'foreignKey': foreignKey0,
      'fieldType': fieldType0,
      'fieldPath': fieldPath0,
      'fallback': fallback0,
      'description': description0,
      'children': children0,
    };
    return includeNulls ? withNulls : withNulls.nonNulls;
  } catch (e) {
    assert(false, '$FieldModel.toJson: $e');
    rethrow;
  }
}