p-hatan/ mirror

pub repository

mirror.p-hatan.ir

code_assets

0.19.7

This library contains the hook protocol specification for bundling native code with Dart packages.

Download archive

Readme

package:code_assets Coverage Status pub package package publisher

A library to use in build hooks (hook/build.dart) for building and bundling code assets.

A code asset is an asset containing executable code which respects the native application binary interface (ABI).

Code assets can be added in a build hook as follows:

import 'package:code_assets/code_assets.dart';
import 'package:hooks/hooks.dart';

void main(List<String> args) async {
  await build(args, (input, output) async {
    final packageName = input.packageName;
    final assetPath = input.outputDirectory.resolve('...');

    output.assets.code.add(
      CodeAsset(
        package: packageName,
        name: '...',
        linkMode: DynamicLoadingBundled(),
        file: assetPath,
      ),
    );
  });
}

For more documentation of hooks, refer to the API docs of package:hooks.

When compiling C, C++ or Objective-C code from source, consider using package:native_toolchain_c.

Status: In Preview

NOTE: This package is currently in preview and published under the labs.dart.dev pub publisher in order to solicit feedback.

For packages in the labs.dart.dev publisher we generally plan to either graduate the package into a supported publisher (dart.dev, tools.dart.dev) after a period of feedback and iteration, or discontinue the package. These packages have a much higher expected rate of API and breaking changes.

Your feedback is valuable and will help us evolve this package. For bugs, please file an issue in the bug tracker. For general feedback and suggestions for the native assets feature in Dart and Flutter, please comment in dart-lang#50565 or flutter#129757.

Changelog

0.19.7

  • Bump examples to use package:ffigen 20.0.0-dev.0.

0.19.6

  • Added a library comment detailing how to use the package.
  • Fixed duplicate asset id detection with assets coming from both build and link hooks.

0.19.5

  • Bump package:hooks to 0.20.0.

0.19.4

  • Add doc comments to all public members.

0.19.3

  • Mark this package as in preview.

0.19.1

  • Bump the SDK constraint to at least the one from package:hooks to fix dartdoc generation on https://pub.dev.

0.19.0

  • Split up package:native_assets_cli in package:hooks, package:code_assets, and package:data_assets.

0.1.0

  • Initial version.

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add code_assets
pubspec.yaml
name: code_assets
description: >-
  This library contains the hook protocol specification for bundling native code
  with Dart packages.

version: 0.19.7

repository: https://github.com/dart-lang/native/tree/main/pkgs/code_assets

topics:
  - assets
  - ffi
  - hooks
  - interop
  - native-assets

resolution: workspace

environment:
  sdk: '>=3.9.0 <4.0.0'

dependencies:
  collection: ^1.19.1
  hooks: ^0.20.1

dev_dependencies:
  custom_lint: ^0.7.5
  dart_flutter_team_lints: ^3.5.2
  json_schema: ^5.2.0 # May only be used in tool/ and test/json_schema/.
  native_test_helpers:
    path: ../native_test_helpers/
  repo_lint_rules:
    path: ../repo_lint_rules/
  test: ^1.25.15

Version history

VersionPublishedArchiveSHA-256
0.1.0-wip2025-04-01T06:36:09.074999ZDownload402ac1c896e2183932ae7562fee2179e09530539e2d8fcf8488377dd9e63a61e
0.19.02025-05-01T07:48:54.186748ZDownload2d1f99d221a174275a7992152039264dcb69521bb61fb541544187b0eeeda018
0.19.12025-05-21T14:14:35.176372ZDownloada863a007e22fb4fc09077e5fe83933e125176d641faaa6c3a24a747a3d263f9a
0.19.22025-05-21T16:03:48.341954ZDownload052a360e836e657949c3ce98c0744cf32d68ccd634406a35b772828dd5305e56
0.19.32025-05-21T17:44:38.125066ZDownloadd1bacf6f0c507acc817e053f8186b79a600eeed78dbd04edcb8c5a8a07a37e1f
0.19.42025-06-12T11:32:11.738051ZDownloaddd7ed641b7f642092092969f2dcd5845ab31c9f3efead0c06ca437bf9ce8a8b2
0.19.52025-08-04T11:27:33.764955ZDownload7f42899e7b22f7810ea8c2b281c979add25555fbe391dde539621069e20b90b4
0.19.62025-08-27T14:57:14.301202ZDownload3b182b03a2f263ad6ab47cdadf9b64daa1d2d72ac941a277f685fb77ba96cbd5
0.19.72025-09-02T18:11:34.541385ZDownload5865a34983367f6884e8311f67d9ae459945b99bad20c0e66484a1aae7feaae0
0.19.82025-10-13T07:47:53.647276ZDownloadf25d387079d2bfd71341ed2952d107b369bfba49d867d9e29a32101dbd5bdfb2
0.19.92025-10-20T09:36:00.539492ZDownload450f46c55509b7215f2b2ead126bad1567a2edf3207ea0eb7a91d3d508cea0f8
0.19.102025-10-27T12:25:33.463120ZDownloadae0db647e668cbb295a3527f0938e4039e004c80099dce2f964102373f5ce0b5
1.0.02025-11-07T15:23:12.528866ZDownload83ccdaa064c980b5596c35dd64a8d3ecc68620174ab9b90b6343b753aa721687
1.1.02026-05-18T15:37:07.071983ZDownloaddad6bf6b9f4f378b0a69edbf42584d336efd1a9ce15deb1ba591cbb1b5ff440f
1.2.02026-05-27T14:44:06.516402ZDownload67cf6d84013f9c601e42a6f8a6b74c4c0d9dc1a1619d775f2b28b732d3551b85
1.2.12026-06-01T07:31:45.772811ZDownloadbf394f466ba9205f1812a0433b392d6af280f155f56651eda7c18cc32ed493b8
2.0.02026-08-18T07:24:51.463053ZDownloadcfd4f5f575a49c5f10ca856e9846073f1e6c3ee94912377eea5f6cefc5272941
2.1.02026-09-16T15:33:35.119756ZDownload828110d598123b5ea96c00c9f3c72105bf79f8ee36c20a39b26209ade421ec57

Dependencies

collection "^1.19.1"

hooks "^0.20.1"