getBodyClass method

String getBodyClass(
  1. String suffix,
  2. String name,
  3. String parent,
  4. Map? map, [
  5. bool root = false,
  6. bool isMultipart = false,
  7. List<String> paramPath = const [],
])

Implementation

String getBodyClass(
  String suffix,
  String name,
  String parent,
  Map? map, [
  bool root = false,
  bool isMultipart = false,
  List<String> paramPath = const [],
]) {
  if (map == null) return '';
  final apiClassName = ModelClassNameHelper.getClassName(
      listClassNameBody, suffix, name, root, true, parent);
  final classString = '''class $apiClassName extends Equatable {
${setConstractorBody(apiClassName, map, isMultipart, paramPath)}

${setTypeData(map, suffix, listClassNameBody, apiClassName, isMultipart, paramPath)}

${toMapBody(map)}

${setPropsEquatable(map, isMultipart, paramPath)}
}
${map.keys.map((e) => map[e] is Map ? getBodyClass(suffix, e.toString().pascalCase, apiClassName, map[e], false) : '').join()}
${map.keys.map((e) => map[e] is List ? map[e] == null ? '' : (map[e] as List).isEmpty ? '' : (map[e] as List).first is! Map ? '' : getBodyClass(suffix, e.toString().pascalCase, apiClassName, (map[e] as List).first, false) : '').join()}
''';

  return classString;
}