NativeCodeAsset class abstract final

A code Asset which respects the native application binary interface (ABI).

Typical languages which produce code assets that respect the native ABI include C, C++ (with extern "C"), Rust (with extern "C"), and a subset of language features of Objective-C.

Native code assets can be accessed at runtime through native external functions via their asset id:

import 'dart:ffi';

void main() {
  final result = add(14, 28);
  print(result);
}

@Native<Int Function(Int, Int)>(assetId: 'package:my_package/add.dart')
external int add(int a, int b);

There are several types of native code assets:

An application is compiled to run on a specific target os and architecture. Different targets require different assets, so the package developer must specify which asset to bundle for which target.

An asset has different ways of being accessible in the final application. It is either brought in "manually" by having the package developer specify a file path of the asset on the current system, it can be part of the Dart or Flutter SDK (LookupInProcess), or it can be already present in the target system (DynamicLoadingSystem). If the asset is bundled "manually", the Dart or Flutter SDK will take care of copying the asset file from its specified location on the current system into the application bundle.

Implemented types

Constructors

NativeCodeAsset({required String package, required String name, required LinkMode linkMode, required OS os, Uri? file, Architecture? architecture})
Constructs a native code asset.
factory

Properties

architecture Architecture?
The architecture this asset can run on.
no setter
file Uri?
The file to be bundled with the Dart or Flutter application.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
id String
The identifier for this asset.
no setterinherited
linkMode LinkMode
The link mode for this native code.
no setter
os OS
The operating system this asset can run on.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

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

Constants

type → const String