Native<T> class
final
Annotation specifying how to bind an external function to native code.
The annotation applies only to external
function declarations.
A Native-annotated external
function is implemented by native code.
The implementation is found in the native library denoted by assetId.
The compiler and/or runtime provides a binding from assetId to native
library, which depends on the target platform.
The compiler/runtime can then resolve/lookup symbols (identifiers)
against the native library, to find a native function,
and bind an external
Dart function declaration to that native function.
Use this annotation on external
functions to specify that they
are resolved against an asset, and to, optionally, provide overrides
of the default symbol and asset IDs.
The type argument T
to the Native annotation must be a function type
representing the native function's parameter and return types.
The parameter and return types must be subtypes of NativeType.
Example:
@Native<Int64 Function(Int64, Int64)>()
external int sum(int a, int b);
Calling such function will try to resolve the symbol in (in that order)
- the provided or default assetId,
- the native resolver set with
Dart_SetFfiNativeResolver
indart_api.h
, and - the current process.
At least one of those three must provide a binding for the symbol, otherwise the method call fails.
NOTE: This is an experimental feature and may change in the future.
- Annotations
-
- @Since('2.19')
Constructors
Properties
- assetId → String?
-
The ID of the asset in which symbol is resolved, if not using the
default.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isLeaf → bool
-
Whether the function is a leaf function.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- symbol → String?
-
The native symbol to be resolved, if not using the default.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited