toJsonBody method

String toJsonBody(
  1. String className
)

Implementation

String toJsonBody(String className) {
  return checkNestedTypes(type!, (String cleanedType, bool isList, bool isListInList, bool isModel) {
    String conversion;

    if (isListInList) {
      conversion = '$name$isNullableString.map((e) => e.map((e) => e.toJson()).toList()).toList()';
    } else if (isList) {
      if (isModel) {
        conversion = '$name$isNullableString.map((e) => e.toJson()).toList()';
      } else {
        conversion = '$name$isNullableString.map((e) => e.toString()).toList()';
      }
    } else if (isModel) {
      conversion = '$name$isNullableString.toJson()';
    } else if (isDatetime && !isTimeStamp) {
      conversion = '$name$isNullableString.toIso8601String()';
    } else if (isTimeStamp) {
      conversion = '$name$isNullableString.millisecondsSinceEpoch';
    } else {
      conversion = name ?? '';
    }

    return "'$originalName': $conversion";
  });
}