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 = this
        .fieldPath
        ?.map(
          (p0) => p0?.trim().nullIfEmpty,
        )
        .nonNulls
        .nullIfEmpty
        ?.toList();
    final fieldType0 = this.fieldType;
    final nullable0 = this.nullable;
    final child0 = this.child?.toJson();
    final withNulls = {
      'nullable': nullable0,
      'fieldType': fieldType0,
      'fieldPath': fieldPath0,
      'child': child0,
    };
    return includeNulls ? withNulls : withNulls.nonNulls;
  } catch (e) {
    assert(false, 'FieldModel.toJson: $e');
    rethrow;
  }
}