process method

  1. @override
TypeConverter process()
override

Implementation

@override
TypeConverter process() {
  final supertype = _classElement.supertype;
  if (supertype == null) {
    throw ProcessorError(
      message:
          'Only classes that inherit from TypeConverter can be used as type converters.',
      todo: 'Make sure use a class that inherits from TypeConverter.',
      element: _classElement,
    );
  }
  final typeArguments = supertype.typeArguments;
  final fieldType = typeArguments[0];
  final databaseType = typeArguments[1];

  if (!databaseType.isDefaultSqlType) {
    throw ProcessorError(
      message:
          'Type converters have to convert to a database-compatible type.',
      todo:
          'Make the class convert to either int, double, String, bool or Uint8List.',
      element: _classElement,
    );
  }

  return TypeConverter(
    _classElement.displayName,
    fieldType,
    databaseType,
    _typeConverterScope,
  );
}