|
|
@ -1472,6 +1472,53 @@ TypeResult resolveObject( |
|
|
|
..type = MethodType.getter, |
|
|
|
..type = MethodType.getter, |
|
|
|
), |
|
|
|
), |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final defaults = <String>[]; |
|
|
|
|
|
|
|
for (final propertyName in schema.properties!.keys) { |
|
|
|
|
|
|
|
final propertySchema = schema.properties![propertyName]!; |
|
|
|
|
|
|
|
if (propertySchema.default_ != null) { |
|
|
|
|
|
|
|
final value = propertySchema.default_!.toString(); |
|
|
|
|
|
|
|
final result = resolveType( |
|
|
|
|
|
|
|
spec, |
|
|
|
|
|
|
|
state, |
|
|
|
|
|
|
|
propertySchema.type!, |
|
|
|
|
|
|
|
propertySchema, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
defaults.add('..${_toDartName(propertyName)} = ${_valueToEscapedValue(result, value)}'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (defaults.isNotEmpty) { |
|
|
|
|
|
|
|
b.methods.add( |
|
|
|
|
|
|
|
Method( |
|
|
|
|
|
|
|
(final b) => b |
|
|
|
|
|
|
|
..name = '_defaults' |
|
|
|
|
|
|
|
..returns = refer('void') |
|
|
|
|
|
|
|
..static = true |
|
|
|
|
|
|
|
..lambda = true |
|
|
|
|
|
|
|
..annotations.add( |
|
|
|
|
|
|
|
refer('BuiltValueHook').call( |
|
|
|
|
|
|
|
[], |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
'initializeBuilder': refer('true'), |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
..requiredParameters.add( |
|
|
|
|
|
|
|
Parameter( |
|
|
|
|
|
|
|
(final b) => b |
|
|
|
|
|
|
|
..name = 'b' |
|
|
|
|
|
|
|
..type = refer('${state.prefix}${identifier}Builder'), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
..body = Code( |
|
|
|
|
|
|
|
<String?>[ |
|
|
|
|
|
|
|
'b', |
|
|
|
|
|
|
|
...defaults, |
|
|
|
|
|
|
|
].join(), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
); |
|
|
|