This package demonstrates both code-generation directions: schemas converted
to immutable models with @AckInfer(), and hand-written classes converted to
codec schemas with @AckModel(). Annotated examples declare both .ack.dart
and .ack.g.dart parts.
- Primitive typed schemas in
lib/schema_types_primitives.dart - Object schemas in
lib/schema_types_simple.dart - Discriminated schemas in
lib/schema_types_discriminated.dart - Built-in and custom codec schemas in
lib/schema_types_transforms.dart - Edge cases and strict resolution in
lib/schema_types_edge_cases.dart - Cross-schema object models in
lib/pet.dart,lib/user_with_color.dart, andlib/additional_properties_example.dart - Codecs (built-in and custom) in
lib/codecs_example.dart - Hand-written class-first models and sealed unions in
lib/class_first_models.dart, including the required_$ClassAckmixin,AccountSchema.schema/wireSchema, and union facades backed by private codecs
The checked-in generated parts let you use the examples immediately:
import 'package:ack_example/class_first_models.dart';
import 'package:ack_example/schema_types_simple.dart';
void main() {
final user = User.parse({'name': 'Ada', 'age': 36, 'active': true});
print(user.name);
final account = Account.fromJson({'display_name': 'Ada'});
print(account.toJson()); // {'display_name': 'Ada', 'role': 'member'}
}dart run melos bootstrap
cd example
dart run build_runner build
dart test