Generic class

A reflectable annotation that marks generic classes for type reflection.

This annotation must be used exclusively on generic class declarations to enable type lookup in the reflection system. It captures the generic type information that would otherwise be erased at runtime.

Usage Requirements:

  • Only valid on generic class declarations (TargetKind.classType)
  • Must specify at least the base type parameter
  • Should include URI for better debugging when possible

{@template generic_annotation_example} Example usage with various generic class patterns:

@Generic(Box, 'dart:core')
class Box<T> {}  // Basic generic class

@Generic(SortedCollection, 'dart:core')
class SortedCollection<T extends Comparable> {}  // Bounded generic

@Generic(Map, 'dart:core')
class Registry<K, V> with Logging implements Storage {}  // With mixins/implements

See also:

Inheritance
Annotations
  • @Target.new({TargetKind.classType})

Constructors

Generic(Type _type, [String? _uri])
Creates a Generic annotation instance.
const

Properties

annotationType Type
Returns the annotation _type of this annotation.
no setteroverride
hashCode int
Returns a hash code consistent with equality definition.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

equals(Object other) bool
Checks whether the given object is logically equivalent to this annotation.
inherited
getType() Type
Gets the preserved generic type information.
getUri() String?
Gets the source location URI if provided.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
Returns a string representation of this annotation.
inherited

Operators

operator ==(Object other) bool
Checks if this annotation is equal to another object.
inherited