-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathclass_first_models.dart
More file actions
43 lines (33 loc) · 912 Bytes
/
Copy pathclass_first_models.dart
File metadata and controls
43 lines (33 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import 'package:ack/ack.dart';
import 'package:ack_annotations/ack_annotations.dart';
part 'class_first_models.ack.dart';
part 'class_first_models.ack.g.dart';
@AckModel(caseStyle: AckCaseStyle.snake)
final class Account with _$AccountAck {
const Account({
required this.displayName,
this.website,
this.role = 'member',
});
@MinLength(2)
final String displayName;
final Uri? website;
final String role;
static final fromJson = AccountSchema.fromJson;
}
@AckModel(discriminatorKey: 'type')
sealed class Pet with _$PetAck {
const Pet({required this.id});
final String id;
}
@AckModel(discriminatorValue: 'cat')
final class Cat extends Pet with _$CatAck {
const Cat({required super.id, required this.lives});
@Min(1)
@Max(9)
final int lives;
}
final class Dog extends Pet with _$DogAck {
const Dog({required super.id, required this.breed});
final String breed;
}