Skip to content

Latest commit

 

History

History

README.md

Ack Example Package

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.

Included examples

Try both generation directions

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'}
}

Running the examples

dart run melos bootstrap
cd example
dart run build_runner build
dart test