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);
      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);
      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);
      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(','));
      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<String, dynamic>) {
        self.type = key?.toTitleCase();
        self.nestedClasses?.add(JsonModel.fromMap('nested', value));
        return self;
      }
      self.type = value.runtimeType.toString();
      return self;
    },
  ),
];