setConstractor method

String setConstractor(
  1. String apiClassName,
  2. Map map, [
  3. bool isMultipart = false,
  4. List<String> paramPath = const [],
])

Implementation

String setConstractor(
  String apiClassName,
  Map map, [
  bool isMultipart = false,
  List<String> paramPath = const [],
]) {
  final variable = map.keys;
  if (variable.isEmpty && paramPath.isEmpty) {
    return 'const $apiClassName(${isMultipart ? '{ this.files }' : ''});';
  }
  return '''const $apiClassName({
  ${isMultipart ? 'this.files,' : ''}
  ${paramPath.map((e) => 'this.${e.camelCase},').join('    \n')}
  ${variable.map((e) => 'this.${e.toString().camelCase},').join('    \n')}
});''';
}