@@ -32,9 +32,7 @@ extension type DartFromRecordOnDartObjectX(_DartObject dartObj) {
32
32
/// Returns `fieldName` property from [dartObj] if it matches the structure of
33
33
/// [TFieldRecord] or `null` .
34
34
List <String >? fieldPathFromRecord () {
35
- return _rawFieldPathFromRecord ()
36
- ? .map ((e) => e.replaceAll ('?' , '' ))
37
- .toList ();
35
+ return _rawFieldPathFromRecord ()? .map ((e) => e.replaceAll ('?' , '' )).toList ();
38
36
}
39
37
40
38
List <String >? _rawFieldPathFromRecord () {
@@ -50,24 +48,20 @@ extension type DartFromRecordOnDartObjectX(_DartObject dartObj) {
50
48
String ? fieldTypeFromRecord () {
51
49
final raw = _rawFieldTypeFromRecord ();
52
50
if (raw != null ) {
53
- return raw.endsWith ('?' ) ? raw.substring (0 , raw.length - 1 ) : raw;
51
+ return raw.endsWith ('?' ) || raw. endsWith ( '*' ) ? raw.substring (0 , raw.length - 1 ) : raw;
54
52
}
55
53
return null ;
56
54
}
57
55
58
56
String ? _rawFieldTypeFromRecord () {
59
57
final a = dartObj.getField ('\$ 2' )? .toStringValue () as String ? ;
60
58
final b =
61
- dartObj.getField ('\$ 2' )? .toTypeValue ()? .getDisplayString () as String ? ;
62
- final c =
63
- dartObj.getField (FieldModelFieldNames .fieldType)? .toStringValue ()
64
- as String ? ;
65
- final d =
66
- dartObj
67
- .getField (FieldModelFieldNames .fieldType)
68
- ? .toTypeValue ()
69
- ? .getDisplayString ()
70
- as String ? ;
59
+ dartObj.getField ('\$ 2' )? .toTypeValue ()? .getDisplayString (withNullability: true ) as String ? ;
60
+ final c = dartObj.getField (FieldModelFieldNames .fieldType)? .toStringValue () as String ? ;
61
+ final d = dartObj
62
+ .getField (FieldModelFieldNames .fieldType)
63
+ ? .toTypeValue ()
64
+ ? .getDisplayString (withNullability: true ) as String ? ;
71
65
return a ?? b ?? c ?? d;
72
66
}
73
67
@@ -78,8 +72,7 @@ extension type DartFromRecordOnDartObjectX(_DartObject dartObj) {
78
72
return false ;
79
73
}
80
74
81
- final a =
82
- dartObj.getField (FieldModelFieldNames .nullable)? .toBoolValue () as bool ? ;
75
+ final a = dartObj.getField (FieldModelFieldNames .nullable)? .toBoolValue () as bool ? ;
83
76
final b = dartObj.getField ('\$ 3' )? .toBoolValue () as bool ? ;
84
77
final c = _rawFieldPathFromRecord ()? .any ((e) => e.contains ('?' ));
85
78
final d = _rawFieldTypeFromRecord ()? .endsWith ('?' );
@@ -89,32 +82,25 @@ extension type DartFromRecordOnDartObjectX(_DartObject dartObj) {
89
82
/// Returns the `children` property from [dartObj] if it matches the structure of
90
83
/// [TFieldRecord] or `null` .
91
84
List <Map <String , dynamic >>? childrenFromRecord () {
92
- final a =
93
- dartObj
94
- .getField (FieldModelFieldNames .children)
95
- ? .toListValue ()
96
- ? .map (
97
- (e) => e.toMapValue ()! .map (
98
- (k, v) => MapEntry (k! .toStringValue ()! , dartObjToObject (v)),
99
- ),
100
- )
101
- as Iterable ? ;
85
+ final a = dartObj.getField (FieldModelFieldNames .children)? .toListValue ()? .map (
86
+ (e) => e.toMapValue ()! .map (
87
+ (k, v) => MapEntry (k! .toStringValue ()! , dartObjToObject (v)),
88
+ ),
89
+ ) as Iterable ? ;
102
90
final b = a? .map ((e) => (e as Map ).cast <String , dynamic >()).toList ();
103
91
return b;
104
92
}
105
93
106
94
/// Returns the `primaryKey` property from [dartObj] if it matches the structure
107
95
/// of [TFieldRecord] or `null` .
108
96
bool ? primaryKeyFromRecord () {
109
- return dartObj.getField (FieldModelFieldNames .primaryKey)? .toBoolValue ()
110
- as bool ? ;
97
+ return dartObj.getField (FieldModelFieldNames .primaryKey)? .toBoolValue () as bool ? ;
111
98
}
112
99
113
100
/// Returns the `foreignKey` property from [dartObj] if it matches the
114
101
/// structure of [TFieldRecord] or `null` .
115
102
bool ? foreignKeyFromRecord () {
116
- return dartObj.getField (FieldModelFieldNames .foreignKey)? .toBoolValue ()
117
- as bool ? ;
103
+ return dartObj.getField (FieldModelFieldNames .foreignKey)? .toBoolValue () as bool ? ;
118
104
}
119
105
120
106
/// Retrieves the `fallback` property from this `DartObject` if it matches
@@ -127,7 +113,6 @@ extension type DartFromRecordOnDartObjectX(_DartObject dartObj) {
127
113
/// Returns the `description` property from [dartObj] record if it matches the
128
114
/// structure of [TFieldRecord] or `null` .
129
115
String ? descriptionFromRecord () {
130
- return dartObj.getField (FieldModelFieldNames .description)? .toStringValue ()
131
- as String ? ;
116
+ return dartObj.getField (FieldModelFieldNames .description)? .toStringValue () as String ? ;
132
117
}
133
118
}
0 commit comments