/
models.dart
114 lines (97 loc) · 3.02 KB
/
models.dart
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import 'package:freezed_annotation/freezed_annotation.dart';
part 'models.freezed.dart';
class GenericsParameterTemplate {}
class GenericsDefinitionTemplate {}
class ParametersTemplate {}
class Property {
late String name;
}
class AssertTemplate {}
class LateGetter {}
class Element {}
String constructorNameToCallbackName(String name) => name;
/// A generated property that has for type a class generated using Freezed
///
/// This allows Freezed to support deep copy of the object.
/// This does include primitives like [int] and [List].
@freezed
class DeepCloneableProperty with _$DeepCloneableProperty {
factory DeepCloneableProperty({
required String name,
required String typeName,
required String type,
required bool nullable,
required GenericsParameterTemplate genericParameters,
}) = _DeepCloneableProperty;
}
/// The information of a specific constructor of a class tagged with `@freezed`.
///
/// This only includes constructors where Freezed needs to generate something.
@freezed
class ConstructorDetails with _$ConstructorDetails {
factory ConstructorDetails({
required String name,
required String unionValue,
required bool isConst,
required String redirectedName,
required ParametersTemplate parameters,
required List<Property> impliedProperties,
required bool isDefault,
required bool isFallback,
required bool hasJsonSerializable,
required String fullName,
required String escapedName,
required List<String> withDecorators,
required List<String> implementsDecorators,
required List<String> decorators,
required List<DeepCloneableProperty> cloneableProperties,
required List<AssertTemplate> asserts,
}) = _ConstructorDetails;
ConstructorDetails._();
String get callbackName => constructorNameToCallbackName(name);
}
@freezed
class MapConfig with _$MapConfig {
factory MapConfig({
required bool map,
required bool mapOrNull,
required bool maybeMap,
}) = _MapConfig;
}
@freezed
class WhenConfig with _$WhenConfig {
factory WhenConfig({
required bool when,
required bool whenOrNull,
required bool maybeWhen,
}) = _WhenConfig;
}
@freezed
class Data with _$Data {
@Assert('constructors.isNotEmpty')
factory Data({
required String name,
required String unionKey,
required bool generateCopyWith,
required bool generateEqual,
required bool generateToString,
required MapConfig map,
required WhenConfig when,
required bool generateFromJson,
required bool generateToJson,
required bool makeCollectionsImmutable,
required List<String> concretePropertiesName,
required List<ConstructorDetails> constructors,
required GenericsDefinitionTemplate genericsDefinitionTemplate,
required GenericsParameterTemplate genericsParameterTemplate,
required bool shouldUseExtends,
required bool genericArgumentFactories,
}) = _Data;
}
@freezed
class GlobalData with _$GlobalData {
factory GlobalData({
required bool hasJson,
required bool hasDiagnostics,
}) = _GlobalData;
}