# data_assets 0.20.0

This library contains the hook protocol specification for bundling data assets with Dart packages.




## Installing
```
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add 'data_assets:0.20.0'
```
Published: 2026-05-18T15:37:13.174191Z
Expected archive SHA-256: 8bfdbf25ec8a0f4b5a3c993042c4ab9996ba354f0b03d40f4e360f3730d71cae

Available in cache; verification: upstream_checksum
## Direct dependencies
- hooks: ^2.0.0

## Package README (untrusted upstream documentation)
[![package:data_assets](https://github.com/dart-lang/native/actions/workflows/native.yaml/badge.svg)](https://github.com/dart-lang/native/actions/workflows/native.yaml)
[![Coverage Status](https://coveralls.io/repos/github/dart-lang/native/badge.svg?branch=main)](https://coveralls.io/github/dart-lang/native?branch=main)
[![pub package](https://img.shields.io/pub/v/data_assets.svg)](https://pub.dev/packages/data_assets)
[![package publisher](https://img.shields.io/pub/publisher/data_assets.svg)](https://pub.dev/packages/data_assets/publisher)

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

A data asset is an asset bundled as data (String or bytes) with a Dart or
Flutter application.

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

<!-- file://./example/api/data_assets_snippet.dart -->
```dart
import 'package:data_assets/data_assets.dart';
import 'package:hooks/hooks.dart';

void main(List<String> args) async {
  await build(args, (input, output) async {
    if (input.config.buildDataAssets) {
      final packageName = input.packageName;
      final assetPathInPackage = input.packageRoot.resolve('...');
      final assetPathDownload = input.outputDirectoryShared.resolve('...');

      output.assets.data.add(
        DataAsset(
          package: packageName,
          name: '...',
          file: assetPathInPackage,
        ),
      );
    }
  });
}
```

For more documentation of hooks, refer to the API docs of
[`package:hooks`](https://pub.dev/packages/hooks).

## Status: Experimental

**NOTE**: This package is currently experimental and published under the
[labs.dart.dev](https://dart.dev/dart-team-packages) 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](https://github.com/dart-lang/native/issues).


## Changelog
## 0.20.0

- Bumped dependency on `package:hooks` to `^2.0.0` and implemented the new `outputFiles` protocol extension method to track generated data asset files for cache invalidation.

## 0.19.6

- Bump `package:hooks` to 1.0.0.

## 0.19.5

- Document `input.packageRoot` in more places.

## 0.19.4

- Document that asset file paths must be absolute.

## 0.19.3

- Added a library comment detailing how to use the package.

## 0.19.2

- Bump `package:hooks` to 0.20.0.

## 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.







 
