CodeAsset class - code_assets library (original) (raw)

An asset containing executable code 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 CodeConfig.targetOSand CodeConfig.targetArchitecture. 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 afile 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.

Properties

fileUri?

The native library to be bundled with the Dart or Flutter application.

final

hashCodeint

The hash code for this object.

no setteroverride

idString

The id of this code asset.

final

linkModeLinkMode

The link mode for this native code.

final

runtimeTypeType

A representation of the runtime type of the object.

no setterinherited