dart_json_annotations 2.0.0
dart_json_annotations: ^2.0.0 copied to clipboard
High-performance code generation for Dart/Flutter: JSON, copyWith, equatable, and union/sealed class support. Rust-powered CLI with parallel processing.
Changelog #
2.0.0 #
Breaking Changes #
- Unified
@Modelannotation replaces@Json,@CopyWith,@Equatable,@DataClass - Removed legacy annotations (still work but deprecated)
- Changed default behavior:
@Model()now generates JSON only (not full features)
New Features #
-
Preset constructors for common patterns:
@Model()- JSON only (~25 lines)@Model.data()- JSON + copyWith + equatable (~50 lines)@Model.bloc()- copyWith + equatable, no JSON (~35 lines)@Model.full()- All features (~70 lines)@Model.union()- Sealed class with when/map methods
-
Sealed/Union class support:
when()- Exhaustive pattern matchingmaybeWhen()- Optional pattern matching with orElsewhenOrNull()- Nullable pattern matchingmap()- Type-based mappingmaybeMap()- Optional type mapping- Type checkers:
isSuccess,isFailure, etc. - Safe casts:
asSuccess,asFailure, etc.
-
@Ignoreannotation with variants:@Ignore()- Ignore from all features@Ignore.json()- Ignore from JSON only@Ignore.equality()- Ignore from == comparison@Ignore.copyWith()- Ignore from copyWith
-
Parallel processing using Rust's rayon crate (3-4x faster)
-
Compact output - Optimized for large codebases (200+ models)
-
--threadsoption to control parallelism
Performance #
- 70% smaller output size with
@Model()preset - File-level shared helpers instead of per-class
- Lazy regex compilation
- Pre-allocated string buffers