toMockDeclaration method

String toMockDeclaration(
  1. String className
)

Implementation

String toMockDeclaration(String className) {
  final value = checkNestedTypes(type!, (String cleanedType, bool isList, bool isListInList, bool isModel) {
    final fakerMaker = FakerMaker(this, className, cleanedType, isModel);
    final fakerDeclaration = fakerMaker.generate();

    if (isListInList) {
      return 'List.generate(5, (_) => List.generate(5, (_) => $fakerDeclaration))';
    } else if (isList) {
      return 'List.generate(5, (_) => $fakerDeclaration)';
    } else {
      return fakerDeclaration;
    }
  });

  if (isNullable) {
    return '$name: checkOptional($name, () => $value)'.trim().indented();
  } else {
    return '$name: $name ?? $value'.trim().indented();
  }
}