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 ? 'required this.files,' : ''}
  ${paramPath.map((e) => 'required this.${e.camelCase},').join('    \n')}
  ${variable.map((e) => 'required this.${e.toString().camelCase},').join('    \n')}
});''';
}