Skip to content

FunctionTypeMirror abstract

abstract class FunctionTypeMirror implements ClassMirror

A FunctionTypeMirror represents the type of a function in the Dart language.

Implemented types

Constructors

FunctionTypeMirror()

FunctionTypeMirror()

Properties

callMethod no setter

MethodMirror get callMethod

A mirror on the call method for the reflectee.

Implementation
dart
// This is only here because in the past the VM did not implement a call
// method on closures.
MethodMirror get callMethod;

declarations no setter inherited

Map<Symbol, DeclarationMirror> get declarations

Returns an immutable map of the declarations actually given in the class declaration.

This map includes all regular methods, getters, setters, fields, constructors and type variables actually declared in the class. Both static and instance members are included, but no inherited members are included. The map is keyed by the simple names of the declarations.

This does not include inherited members.

Inherited from ClassMirror.

Implementation
dart
Map<Symbol, DeclarationMirror> get declarations;

hashCode no setter inherited

int get hashCode

The hash code for this object.

A hash code is a single integer which represents the state of the object that affects operator == comparisons.

All objects have hash codes. The default hash code implemented by Object represents only the identity of the object, the same way as the default operator == implementation only considers objects equal if they are identical (see identityHashCode).

If operator == is overridden to use the object state instead, the hash code must also be changed to represent that state, otherwise the object cannot be used in hash based data structures like the default Set and Map implementations.

Hash codes must be the same for objects that are equal to each other according to operator ==. The hash code of an object should only change if the object changes in a way that affects equality. There are no further requirements for the hash codes. They need not be consistent between executions of the same program and there are no distribution guarantees.

Objects that are not equal are allowed to have the same hash code. It is even technically allowed that all instances have the same hash code, but if clashes happen too often, it may reduce the efficiency of hash-based data structures like HashSet or HashMap.

If a subclass overrides hashCode, it should override the operator == operator as well to maintain consistency.

Inherited from Object.

Implementation
dart
external int get hashCode;

hasReflectedType no setter inherited

bool get hasReflectedType

Returns true if this mirror reflects dynamic, a non-generic class or typedef, or an instantiated generic class or typedef in the current isolate. Otherwise, returns false.

Inherited from TypeMirror.

Implementation
dart
bool get hasReflectedType;

instanceMembers no setter inherited

Map<Symbol, MethodMirror> get instanceMembers

Returns a map of the methods, getters and setters of an instance of the class.

The intent is to capture those members that constitute the API of an instance. Hence fields are not included, but the getters and setters implicitly introduced by fields are included. The map includes methods, getters and setters that are inherited as well as those introduced by the class itself.

The map is keyed by the simple names of the members.

Inherited from ClassMirror.

Implementation
dart
Map<Symbol, MethodMirror> get instanceMembers;

isAbstract no setter inherited

bool get isAbstract

Is the reflectee abstract?

Inherited from ClassMirror.

Implementation
dart
bool get isAbstract;

isEnum no setter inherited

bool get isEnum

Is the reflectee an enum?

Inherited from ClassMirror.

Implementation
dart
bool get isEnum;

isOriginalDeclaration no setter inherited

bool get isOriginalDeclaration

Is this the original declaration of this type?

For most classes, they are their own original declaration. For generic classes, however, there is a distinction between the original class declaration, which has unbound type variables, and the instantiations of generic classes, which have bound type variables.

Inherited from TypeMirror.

Implementation
dart
bool get isOriginalDeclaration;

isPrivate no setter inherited

bool get isPrivate

Whether this declaration is library private.

Always returns false for a library declaration, otherwise returns true if the declaration's name starts with an underscore character (_), and false if it doesn't.

Inherited from DeclarationMirror.

Implementation
dart
bool get isPrivate;

isTopLevel no setter inherited

bool get isTopLevel

Whether this declaration is top-level.

A declaration is considered top-level if its owner is a LibraryMirror.

Inherited from DeclarationMirror.

Implementation
dart
bool get isTopLevel;

location no setter inherited

SourceLocation? get location

The source location of this Dart language entity, or null if the entity is synthetic.

If the reflectee is a variable, the returned location gives the position of the variable name at its point of declaration.

If the reflectee is a library, class, typedef, function or type variable with associated metadata, the returned location gives the position of the first metadata declaration associated with the reflectee.

Otherwise:

If the reflectee is a library, the returned location gives the position of the keyword 'library' at the reflectee's point of declaration, if the reflectee is a named library, or the first character of the first line in the compilation unit defining the reflectee if the reflectee is anonymous.

If the reflectee is an abstract class, the returned location gives the position of the keyword 'abstract' at the reflectee's point of declaration. Otherwise, if the reflectee is a class, the returned location gives the position of the keyword 'class' at the reflectee's point of declaration.

If the reflectee is a typedef the returned location gives the position of the of the keyword 'typedef' at the reflectee's point of declaration.

If the reflectee is a function with a declared return type, the returned location gives the position of the function's return type at the reflectee's point of declaration. Otherwise. the returned location gives the position of the function's name at the reflectee's point of declaration.

This operation is optional and may throw an UnsupportedError.

Inherited from DeclarationMirror.

Implementation
dart
SourceLocation? get location;

metadata no setter inherited

List<InstanceMirror> get metadata

A list of the metadata associated with this declaration.

Let D be the declaration this mirror reflects. If D is decorated with annotations A1, ..., An where n > 0, then for each annotation Ai associated with D, 1 <= i <= n, let ci be the constant object specified by Ai. Then this method returns a list whose members are instance mirrors on c1, ..., cn. If no annotations are associated with D, then an empty list is returned.

If evaluating any of c1, ..., cn would cause a compilation error the effect is the same as if a non-reflective compilation error had been encountered.

Inherited from DeclarationMirror.

Implementation
dart
List<InstanceMirror> get metadata;

mixin no setter inherited

ClassMirror get mixin

The mixin of this class.

If this class is the result of a mixin application of the form S with M, returns a class mirror on M. Otherwise returns a class mirror on the reflectee.

Inherited from ClassMirror.

Implementation
dart
ClassMirror get mixin;

originalDeclaration no setter inherited

TypeMirror get originalDeclaration

A mirror on the original declaration of this type.

For most classes, they are their own original declaration. For generic classes, however, there is a distinction between the original class declaration, which has unbound type variables, and the instantiations of generic classes, which have bound type variables.

Inherited from TypeMirror.

Implementation
dart
TypeMirror get originalDeclaration;

owner no setter inherited

A mirror on the owner of this Dart language entity.

The owner is the declaration immediately surrounding the reflectee:

  • For a library, the owner is null.
  • For a class declaration, typedef or top level function or variable, the owner is the enclosing library.
  • For a mixin application S with M, the owner is the owner of M.
  • For a constructor, the owner is the immediately enclosing class.
  • For a method, instance variable or a static variable, the owner is the immediately enclosing class, unless the class is a mixin application S with M, in which case the owner is M. Note that M may be an invocation of a generic.
  • For a parameter, local variable or local function the owner is the immediately enclosing function.

Inherited from DeclarationMirror.

Implementation
dart
DeclarationMirror? get owner;

parameters no setter

List<ParameterMirror> get parameters

Returns a list of the parameter types of the reflectee.

Implementation
dart
List<ParameterMirror> get parameters;

qualifiedName no setter inherited

Symbol get qualifiedName

The fully-qualified name for this Dart language entity.

This name is qualified by the name of the owner. For instance, the qualified name of a method 'method' in class 'Class' in library 'library' is 'library.Class.method'.

Returns a Symbol constructed from a string representing the fully qualified name of the reflectee. Let o be the owner of this mirror, let r be the reflectee of this mirror, let p be the fully qualified name of the reflectee of o, and let s be the simple name of r computed by simpleName. The fully qualified name of r is the concatenation of p, '.', and s.

Because an isolate can contain more than one library with the same name (at different URIs), a fully-qualified name does not uniquely identify any language entity.

Inherited from DeclarationMirror.

Implementation
dart
Symbol get qualifiedName;

reflectedType no setter inherited

Type get reflectedType

If hasReflectedType returns true, returns the corresponding Type. Otherwise, an UnsupportedError is thrown.

Inherited from TypeMirror.

Implementation
dart
Type get reflectedType;

returnType no setter

TypeMirror get returnType

Returns the return type of the reflectee.

Implementation
dart
TypeMirror get returnType;

runtimeType no setter inherited

Type get runtimeType

A representation of the runtime type of the object.

Inherited from Object.

Implementation
dart
external Type get runtimeType;

simpleName no setter inherited

Symbol get simpleName

The simple name for this Dart language entity.

The simple name is in most cases the identifier name of the entity, such as 'myMethod' for a method, void myMethod() {...} or 'mylibrary' for a library 'mylibrary'; declaration.

Inherited from DeclarationMirror.

Implementation
dart
Symbol get simpleName;

staticMembers no setter inherited

Map<Symbol, MethodMirror> get staticMembers

Returns a map of the static methods, getters and setters of the class.

The intent is to capture those members that constitute the API of a class. Hence fields are not included, but the getters and setters implicitly introduced by fields are included.

The map is keyed by the simple names of the members.

Inherited from ClassMirror.

Implementation
dart
Map<Symbol, MethodMirror> get staticMembers;

superclass no setter inherited

ClassMirror? get superclass

A mirror on the superclass on the reflectee.

If this type is Object, the superclass will be null.

Inherited from ClassMirror.

Implementation
dart
ClassMirror? get superclass;

superinterfaces no setter inherited

List<ClassMirror> get superinterfaces

A list of mirrors on the superinterfaces of the reflectee.

Inherited from ClassMirror.

Implementation
dart
List<ClassMirror> get superinterfaces;

typeArguments no setter inherited

List<TypeMirror> get typeArguments

An immutable list with mirrors for all type arguments for this type.

If the reflectee is an invocation of a generic class, the type arguments are the bindings of its type parameters. If the reflectee is the original declaration of a generic, it has no type arguments and this method returns an empty list. If the reflectee is not generic, then it has no type arguments and this method returns an empty list.

This list preserves the order of declaration of the type variables.

Inherited from TypeMirror.

Implementation
dart
List<TypeMirror> get typeArguments;

typeVariables no setter inherited

List<TypeVariableMirror> get typeVariables

An immutable list with mirrors for all type variables for this type.

If this type is a generic declaration or an invocation of a generic declaration, the returned list contains mirrors on the type variables declared in the original declaration. Otherwise, the returned list is empty.

This list preserves the order of declaration of the type variables.

Inherited from TypeMirror.

Implementation
dart
List<TypeVariableMirror> get typeVariables;

Methods

delegate() inherited

dynamic delegate(Invocation invocation)

Performs invocation on the reflectee of this ObjectMirror.

Equivalent to

dart
if (invocation.isGetter) {
  return this.getField(invocation.memberName).reflectee;
} else if (invocation.isSetter) {
  return this.setField(invocation.memberName,
                       invocation.positionalArguments[0]).reflectee;
} else {
  return this.invoke(invocation.memberName,
                     invocation.positionalArguments,
                     invocation.namedArguments).reflectee;
}

Inherited from ObjectMirror.

Implementation
dart
delegate(Invocation invocation);

getField() inherited

InstanceMirror getField(Symbol fieldName)

Invokes a getter and returns a mirror on the result.

The getter can be the implicit getter for a field or a user-defined getter method.

Let o be the object reflected by this mirror, let f be the simple name of the getter denoted by fieldName.

Then this method will perform the getter invocation o.f in a scope that has access to the private members of o (if o is a class or library) or the private members of the class of o (otherwise).

If this mirror is an InstanceMirror, and fieldName denotes an instance method on its reflectee, the result of the invocation is an instance mirror on a closure corresponding to that method.

If this mirror is a LibraryMirror, and fieldName denotes a top-level method in the corresponding library, the result of the invocation is an instance mirror on a closure corresponding to that method.

If this mirror is a ClassMirror, and fieldName denotes a static method in the corresponding class, the result of the invocation is an instance mirror on a closure corresponding to that method.

If the invocation returns a result r, this method returns the result of calling reflect(r).

If the invocation causes a compilation error, the effect is the same as if a non-reflective compilation error had been encountered.

If the invocation throws an exception e (that it does not catch), this method throws e.

Inherited from ObjectMirror.

Implementation
dart
&#47;&#47; TODO(ahe): Remove stuff about scope and private members. [fieldName] is a
&#47;&#47; capability giving access to private members.
InstanceMirror getField(Symbol fieldName);

invoke() inherited

InstanceMirror invoke(
  Symbol memberName,
  List<dynamic> positionalArguments, [
  Map<Symbol, dynamic> namedArguments = const <Symbol, dynamic>{},
])

Invokes the named function and returns a mirror on the result.

Let o be the object reflected by this mirror, let f be the simple name of the member denoted by memberName, let a1, ..., an be the elements of positionalArguments, let k1, ..., km be the identifiers denoted by the elements of namedArguments.keys, and let v1, ..., vm be the elements of namedArguments.values. Then this method will perform the method invocation o.f(a1, ..., an, k1: v1, ..., km: vm) in a scope that has access to the private members of o (if o is a class or library) or the private members of the class of o (otherwise).

If the invocation returns a result r, this method returns the result of calling reflect(r).

If the invocation causes a compilation error the effect is the same as if a non-reflective compilation error had been encountered.

If the invocation throws an exception e (that it does not catch), this method throws e.

Inherited from ObjectMirror.

Implementation
dart
InstanceMirror invoke(
  Symbol memberName,
  List<dynamic> positionalArguments, [
  Map<Symbol, dynamic> namedArguments = const <Symbol, dynamic>{},
]);

isAssignableTo() inherited

bool isAssignableTo(TypeMirror other)

Checks the assignability relationship, denoted by <=> in the language specification.

This is the type relationship tested on assignment in checked mode.

Inherited from TypeMirror.

Implementation
dart
bool isAssignableTo(TypeMirror other);

isSubclassOf() inherited

bool isSubclassOf(ClassMirror other)

Returns whether the class denoted by the receiver is a subclass of the class denoted by the argument.

Note that the subclass relationship is reflexive.

Inherited from ClassMirror.

Implementation
dart
bool isSubclassOf(ClassMirror other);

isSubtypeOf() inherited

bool isSubtypeOf(TypeMirror other)

Checks the subtype relationship, denoted by <: in the language specification.

This is the type relationship used in is test checks.

Inherited from TypeMirror.

Implementation
dart
bool isSubtypeOf(TypeMirror other);

newInstance() inherited

InstanceMirror newInstance(
  Symbol constructorName,
  List<dynamic> positionalArguments, [
  Map<Symbol, dynamic> namedArguments = const <Symbol, dynamic>{},
])

Invokes the named constructor and returns a mirror on the result.

Let c be the class reflected by this mirror, let a1, ..., an be the elements of positionalArguments, let k1, ..., km be the identifiers denoted by the elements of namedArguments.keys, and let v1, ..., vm be the elements of namedArguments.values.

If constructorName was created from the empty string, then this method will execute the instance creation expression new c(a1, ..., an, k1: v1, ..., km: vm) in a scope that has access to the private members of c.

Otherwise, let f be the simple name of the constructor denoted by constructorName. Then this method will execute the instance creation expression new c.f(a1, ..., an, k1: v1, ..., km: vm) in a scope that has access to the private members of c.

In either case:

  • If the expression evaluates to a result r, this method returns the result of calling reflect(r).
  • If evaluating the expression causes a compilation error, the effect is the same as if a non-reflective compilation error had been encountered.
  • If evaluating the expression throws an exception e (that it does not catch), this method throws e.

Inherited from ClassMirror.

Implementation
dart
InstanceMirror newInstance(
  Symbol constructorName,
  List<dynamic> positionalArguments, [
  Map<Symbol, dynamic> namedArguments = const <Symbol, dynamic>{},
]);

noSuchMethod() inherited

dynamic noSuchMethod(Invocation invocation)

Invoked when a nonexistent method or property is accessed.

A dynamic member invocation can attempt to call a member which doesn't exist on the receiving object. Example:

dart
dynamic object = 1;
object.add(42); // Statically allowed, run-time error

This invalid code will invoke the noSuchMethod method of the integer 1 with an Invocation representing the .add(42) call and arguments (which then throws).

Classes can override noSuchMethod to provide custom behavior for such invalid dynamic invocations.

A class with a non-default noSuchMethod invocation can also omit implementations for members of its interface. Example:

dart
class MockList<T> implements List<T> {
  noSuchMethod(Invocation invocation) {
    log(invocation);
    super.noSuchMethod(invocation); // Will throw.
  }
}
void main() {
  MockList().add(42);
}

This code has no compile-time warnings or errors even though the MockList class has no concrete implementation of any of the List interface methods. Calls to List methods are forwarded to noSuchMethod, so this code will log an invocation similar to Invocation.method(#add, [42]) and then throw.

If a value is returned from noSuchMethod, it becomes the result of the original invocation. If the value is not of a type that can be returned by the original invocation, a type error occurs at the invocation.

The default behavior is to throw a NoSuchMethodError.

Inherited from Object.

Implementation
dart
@pragma("vm:entry-point")
@pragma("wasm:entry-point")
external dynamic noSuchMethod(Invocation invocation);

setField() inherited

InstanceMirror setField(Symbol fieldName, dynamic value)

Invokes a setter and returns a mirror on the result.

The setter may be either the implicit setter for a non-final field or a user-defined setter method.

Let o be the object reflected by this mirror, let f be the simple name of the getter denoted by fieldName, and let a be the object bound to value.

Then this method will perform the setter invocation o.f = a in a scope that has access to the private members of o (if o is a class or library) or the private members of the class of o (otherwise).

If the invocation returns a result r, this method returns the result of calling reflect(value).

If the invocation causes a compilation error, the effect is the same as if a non-reflective compilation error had been encountered.

If the invocation throws an exception e (that it does not catch) this method throws e.

Inherited from ObjectMirror.

Implementation
dart
InstanceMirror setField(Symbol fieldName, dynamic value);

toString() inherited

String toString()

A string representation of this object.

Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string representation.

Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.

Inherited from Object.

Implementation
dart
external String toString();

Operators

operator ==() inherited

bool operator ==(Object other)

The equality operator.

The default behavior for all Objects is to return true if and only if this object and other are the same object.

Override this method to specify a different equality relation on a class. The overriding method must still be an equivalence relation. That is, it must be:

  • Total: It must return a boolean for all arguments. It should never throw.

  • Reflexive: For all objects o, o == o must be true.

  • Symmetric: For all objects o1 and o2, o1 == o2 and o2 == o1 must either both be true, or both be false.

  • Transitive: For all objects o1, o2, and o3, if o1 == o2 and o2 == o3 are true, then o1 == o3 must be true.

The method should also be consistent over time, so whether two objects are equal should only change if at least one of the objects was modified.

If a subclass overrides the equality operator, it should override the hashCode method as well to maintain consistency.

Inherited from Object.

Implementation
dart
external bool operator ==(Object other);