Line data Source code
1 : class ImportableType {
2 : final String? import;
3 : final String? name;
4 : final String className;
5 : final bool isRequired;
6 : final bool isNullable;
7 : final List<ImportableType> typeArguments;
8 :
9 2 : String get argumentName => name ?? className;
10 :
11 7 : const ImportableType({
12 : required this.className,
13 : this.name,
14 : this.import,
15 : this.isRequired = false,
16 : this.isNullable = false,
17 : this.typeArguments = const [],
18 : });
19 :
20 0 : Map<String, dynamic> toMap() {
21 0 : return <String, dynamic>{
22 0 : 'import': import,
23 0 : 'className': className,
24 0 : 'name': name,
25 0 : 'isRequired': isRequired,
26 0 : 'isNullable': isNullable,
27 0 : 'typeArguments': typeArguments.map((x) => x.toMap()).toList(),
28 : };
29 : }
30 :
31 0 : factory ImportableType.fromMap(Map<String, dynamic> map) {
32 0 : return ImportableType(
33 0 : import: map['import'] as String?,
34 0 : className: map['className'] as String? ?? '',
35 0 : name: map['name'] as String?,
36 0 : isRequired: map['isRequired'] == true,
37 0 : isNullable: map['isNullable'] == true,
38 0 : typeArguments: List<ImportableType>.from(map['typeArguments']?.map((dynamic x) => ImportableType.fromMap(x as Map<String, dynamic>)) as Iterable),
39 : );
40 : }
41 : }
|