Skip to content
pubscout

hooks

2.2.0, released 3 months ago by dart.dev

Dart API for the JSON-based protocol for package build and link hooks.

$ flutter pub add hooks
Source repository

What it does

Provides a Dart library for writing `hook/build.dart` and `hook/link.dart` scripts to automate building or gathering assets and performing whole-application optimization.

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

Use it when

  • You are building or gathering code assets or native binaries for a Dart package
  • You need to run custom build tasks during a Dart build via hook scripts

Skip it when

  • You are developing standard pure-Dart packages that do not require native asset compilation or hooks

Strengths

  • Standardized protocol for native assets and hooks in Dart
  • Supports user-defines configuration from pubspec.yaml

Weaknesses

  • Niche package restricted to native asset and hook workflows

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
6

Requires setting up build and link scripts within the `hook/` directory of your Dart package.

import 'package:hooks/hooks.dart';

void main(List<String> args) async {
  await build(args, (input, output) async {
    if (input.config.buildCodeAssets) {
      // Build or gather assets
    }
  });
}

Alternatives

Packages that do the same job and could replace hooks.

Works with

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