Skip to content
pubscout

data_assets

0.20.0, released 6 months ago by labs.dart.dev

Protocol specification for bundling data assets with Dart and Flutter packages using build hooks.

$ flutter pub add data_assets
Source repository

What it does

Provides a hook protocol specification to bundle data assets (as strings or bytes) with Dart and Flutter packages. It is designed to be used inside build hooks (`hook/build.dart`).

AI-written summary of version 0.20.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You are writing a build hook for a Dart or Flutter package that needs to bundle data assets.
  • You want to programmatically add data assets during the build process.

Skip it when

  • You need a stable production-ready package, as this is currently experimental with a high rate of breaking changes.
  • You are just bundling standard static assets via pubspec.yaml.

Strengths

  • Enables programmatic bundling of data assets via build hooks.
  • Tracks generated data asset files for cache invalidation.

Weaknesses

  • Experimental package under labs.dart.dev with a high expected rate of breaking changes and API evolution.
  • Limited documentation; requires familiarity with package:hooks.

Setup

Kind
Pure Dart
Effort
Medium
Code generation
No
Direct dependencies
1

Requires setting up build hooks (`hook/build.dart`) and depending on `package:hooks`.

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) {
      output.assets.data.add(
        DataAsset(
          package: input.packageName,
          name: 'my_asset',
          file: input.packageRoot.resolve('assets/data.txt'),
        ),
      );
    }
  });
}

Alternatives

Packages that do the same job and could replace data_assets.

  • buffer

    Utilities and classes for reading and writing byte buffers and binary data streams.

  • ogp_data_extract

    Extracts Open Graph protocol metadata and favicons from web pages.

Works with

Packages commonly used together with data_assets: ones it builds on, ones built on it, and its own family.