valueCommands property

List<Command> valueCommands
final

Implementation

static final List<Command> valueCommands = [
  Command(
    prefix: '\$',
    command: '\[\]',
    callback: (DartDeclaration self, String testSubject,
        {String? key, dynamic value}) {
      var typeName = testSubject
          .substring(3)
          .split('/')
          .last
          .split('\\')
          .last
          .toCamelCase();
      var toImport = testSubject.substring(3);
      self.addImport(toImport);
      // TODO: nullsafety operator
      self.type = 'List<${typeName.toTitleCase()}>?';
      return self;
    },
  ),
  Command(
    prefix: '\$',
    command: '',
    notprefix: '\$\[\]',
    callback: (DartDeclaration self, String testSubject,
        {String? key, dynamic value}) {
      self.setName(key!);

      var typeName = testSubject
          .substring(1)
          .split('/')
          .last
          .split('\\')
          .last
          .toCamelCase();

      var toImport = testSubject.substring(1);
      self.addImport(toImport);
// TODO: nullsafety operator
      var type = '${typeName.toTitleCase()}?';
      self.type = type;

      return self;
    },
  ),
  Command(
    prefix: '\@datetime',
    command: '',
    notprefix: '\$\[\]',
    callback: (DartDeclaration self, String testSubject,
        {String? key, dynamic value}) {
      self.setName(key!);
      // TODO: nullsafety operator
      self.type = 'DateTime?';
      return self;
    },
  ),
  Command(
    prefix: '\@enum',
    command: ':',
    notprefix: '\$\[\]',
    callback: (DartDeclaration self, String testSubject,
        {String? key, dynamic value}) {
      self.setEnumValues(
          (value as String).substring('@enum:'.length).split(','));
      print(key);
      self.setName(key!);
      return self;
    },
  ),
  Command(
    type: dynamic,
    callback: (DartDeclaration self, dynamic testSubject,
        {String? key, dynamic value}) {
      self.setName(key!);

      if (value == null) {
        self.type = 'dynamic';
        return self;
      }
      if (value is Map) {
        // TODO: nullsafety operator
        self.type = '${key.toTitleCase()}?';
        self.nestedClasses.add(JsonModel.fromMap('nested', value));
        return self;
      }
      // TODO: nullsafety operator
      self.type = '${value.runtimeType.toString()}?';
      return self;
    },
  ),
];