derive_annotation 0.1.0 copy "derive_annotation: ^0.1.0" to clipboard
derive_annotation: ^0.1.0 copied to clipboard

Base Dust derive annotations for Dart models and future extension packages.

derive_annotation #

Base Dust derive annotations for Dart.

This package defines the shared annotation contract used by Dust code generation. It contains:

  • the @Derive([...]) container annotation
  • core derive trait markers like ToString, Eq, and CopyWith
  • base extension points for future packages such as derive_serde_annotation
  • a re-export of package:collection/collection.dart so generated deep-equality support can use collection helpers through the same library import

Install Dust #

Install the Dust CLI before using these annotations.

macOS / Linux:

curl -fsSL https://raw.githubusercontent.com/y3l1n4ung/dust/main/install.sh | bash

Windows (PowerShell):

irm https://raw.githubusercontent.com/y3l1n4ung/dust/main/install.ps1 | iex

Or with Cargo:

cargo install dust_cli

Example #

import 'package:derive_annotation/derive_annotation.dart';

part 'user.g.dart';

@Derive([ToString(), Eq(), CopyWith()])
class User with _$UserDust {
  final String id;
  final String? name;

  const User(this.id, this.name);
}

Run Dust:

dust build

Dust writes user.g.dart and the _$UserDust mixin members for toString(), ==, hashCode, and copyWith(...).

Extension packages #

Future packages can extend the base contract by subclassing DeriveTrait or DeriveConfig.

import 'package:derive_annotation/derive_annotation.dart';

final class Serialize extends DeriveTrait {
  const Serialize();
}

final class SerDe extends DeriveConfig {
  const SerDe();
}

Notes #

  • Eq generates both operator == and matching hashCode.
  • ToString() is Dust's public derive marker for generated toString().
0
likes
160
points
120
downloads

Documentation

API reference

Publisher

verified publisherwidget-lab.dev

Weekly Downloads

Base Dust derive annotations for Dart models and future extension packages.

Repository (GitHub)
View/report issues
Contributing

Topics

#codegen #annotations #dust

License

MIT (license)

Dependencies

collection

More

Packages that depend on derive_annotation