hooks
2.2.0, released 3 months ago by dart.dev
Dart API for the JSON-based protocol for package build and link hooks.
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.
- json_schema_builder
Build and validate JSON Schemas in Dart with a fluent, type‑safe API
87Compare - json_schema
Validate JSON data against JSON Schema drafts in Dart.
63Compare - ffi_leak_tracker
Tracks and detects native memory leaks in Dart FFI allocations.
81Compare - flutter_olm
Builds the native Olm library for Android and iOS to be used via dart:ffi.
40Compare
Works with
Packages commonly used together with hooks: ones it builds on, ones built on it, and its own family.
- yamlhooks depends on itA Dart library for parsing YAML documents into Dart data structures.
- cryptohooks depends on itProvides SHA, MD5, and HMAC hashing functions for Dart.
- pub_semverhooks depends on itVersions and version constraints implementing pub's versioning policy.
- logginghooks depends on itProvides configurable logging with levels and stream listeners for Dart apps.
- built_valueSame familyImmutable value types with builders, enum classes and JSON serialization for Dart.
- asyncSame familyUtility classes and helpers that extend Dart's async library.
- testSame familyA full featured library for writing and running Dart tests across platforms.
- typed_dataSame familyUtility functions and classes for easier work with dart:typed_data lists.