Annotation specifying how to bind an external function to native code.
The annotation applies only to
external function declarations.
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 to the Native annotation must be a function type representing the native function's parameter and return types.
@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
- 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.
- assetId → String?
The ID of the asset in which symbol is resolved, if not using the
- hashCode → int
The hash code for this object.
- isLeaf → bool
Whether the function is a leaf function.
- runtimeType → Type
A representation of the runtime type of the object.
- symbol → String?
The native symbol to be resolved, if not using the default.