Appearance
MethodMirror abstract
abstract class MethodMirror implements DeclarationMirrorA MethodMirror reflects a Dart language function, method, constructor, getter, or setter.
Implemented types
Constructors
MethodMirror()
MethodMirror()Properties
constructorName no setter
Symbol get constructorNameThe constructor name for named constructors and factory methods.
For unnamed constructors, this is the empty string. For non-constructors, this is the empty string.
For example, 'bar' is the constructor name for constructor Foo.bar of type Foo.
Implementation
dart
Symbol get constructorName;hashCode no setter inherited
int get hashCodeThe 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;isAbstract no setter
bool get isAbstractIs the reflectee abstract?
Implementation
dart
bool get isAbstract;isConstConstructor no setter
bool get isConstConstructorIs the reflectee a const constructor?
Implementation
dart
bool get isConstConstructor;isConstructor no setter
bool get isConstructorIs the reflectee a constructor?
Implementation
dart
bool get isConstructor;isExtensionMember no setter
bool get isExtensionMemberIs the reflectee an extension method?
Implementation
dart
bool get isExtensionMember;isExtensionTypeMember no setter
bool get isExtensionTypeMemberIs the reflectee an extension type method?
Implementation
dart
bool get isExtensionTypeMember;isFactoryConstructor no setter
bool get isFactoryConstructorIs the reflectee a factory constructor?
Implementation
dart
bool get isFactoryConstructor;isGenerativeConstructor no setter
bool get isGenerativeConstructorIs the reflectee a generative constructor?
Implementation
dart
bool get isGenerativeConstructor;isGetter no setter
bool get isGetterIs the reflectee a getter?
Implementation
dart
bool get isGetter;isOperator no setter
bool get isOperatorIs the reflectee an operator?
Implementation
dart
bool get isOperator;isPrivate no setter inherited
bool get isPrivateWhether 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;isRedirectingConstructor no setter
bool get isRedirectingConstructorIs the reflectee a redirecting constructor?
Implementation
dart
bool get isRedirectingConstructor;isRegularMethod no setter
bool get isRegularMethodIs the reflectee a regular function or method?
A function or method is regular if it is not a getter, setter, or constructor. Note that operators, by this definition, are regular methods.
Implementation
dart
bool get isRegularMethod;isSetter no setter
bool get isSetterIs the reflectee a setter?
Implementation
dart
bool get isSetter;isStatic no setter
bool get isStaticA function is considered non-static iff it is permitted to refer to 'this'.
Note that generative constructors are considered non-static, whereas factory constructors are considered static.
Implementation
dart
bool get isStatic;isSynthetic no setter
bool get isSyntheticReturns true if the reflectee is synthetic, and returns false otherwise.
A reflectee is synthetic if it is a getter or setter implicitly introduced for a field or Type, or if it is a constructor that was implicitly introduced as a default constructor or as part of a mixin application.
Implementation
dart
bool get isSynthetic;isTopLevel no setter inherited
bool get isTopLevelWhether 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 locationThe 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 metadataA 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;owner no setter inherited
DeclarationMirror? get ownerA 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 ofM. - 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 isM. Note thatMmay 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 parametersA list of mirrors on the parameters for the reflectee.
Implementation
dart
List<ParameterMirror> get parameters;qualifiedName no setter inherited
Symbol get qualifiedNameThe 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;returnType no setter
TypeMirror get returnTypeA mirror on the return type for the reflectee.
Implementation
dart
TypeMirror get returnType;runtimeType no setter inherited
Type get runtimeTypeA representation of the runtime type of the object.
Inherited from Object.
Implementation
dart
external Type get runtimeType;simpleName no setter inherited
Symbol get simpleNameThe 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;source no setter
String? get sourceThe source code for the reflectee, if available. Otherwise null.
Implementation
dart
String? get source;Methods
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 errorThis 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);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 ==() override
Whether this mirror is equal to other.
The equality holds if and only if
otheris a mirror of the same kind, andsimpleName == other.simpleNameandowner == other.owner.
Implementation
dart
bool operator ==(Object other);