toon_annotation 1.0.0
toon_annotation: ^1.0.0 copied to clipboard
Annotations and configuration classes for toon_serializable, enabling type-safe TOON conversion in Dart and Flutter projects.
example/main.dart
// example/main.dart
import 'package:toon_annotation/toon_annotation.dart';
// 1. Define a class that uses the ToonSerializable annotation
@ToonSerializable(
fieldRename: FieldRename.snake,
)
class Product {
final int productId;
@ToonKey(name: 'product_name')
final String name;
final double priceInCents;
const Product({
required this.productId,
required this.name,
required this.priceInCents,
});
// NOTE: In a real scenario, the toToon() method would be generated
// by 'toon_serializable'. This example just shows the usage syntax.
@override
String toString() =>
'Product Model: $name (ID: $productId). Ready for TOON serialization.';
}
void main() {
print('--- TOON Annotation Example ---');
const exampleProduct = Product(
productId: 101,
name: 'Electric Screwdriver',
priceInCents: 1999.0,
);
print('Annotated Class Ready: ${exampleProduct.toString()}');
print(
'\nSuccess: The toon_annotation package is correctly imported and its annotations are applied.');
}