File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3221,15 +3221,20 @@ MultipartFile.fromFileSync(i.path,
32213221 final ele = p.type.element! as ClassElement ;
32223222 if (_missingToJson (ele)) {
32233223 if (_isDateTime (p.type)) {
3224- final expr = [
3225- if (p.type.nullabilitySuffix == NullabilitySuffix .question)
3226- refer (
3227- p.displayName,
3228- ).nullSafeProperty ('toIso8601String' ).call ([])
3229- else
3230- refer (p.displayName).property ('toIso8601String' ).call ([]),
3231- ];
3232- refer (dataVar).property ('fields' ).property ('add' ).call (expr);
3224+ if (p.type.nullabilitySuffix == NullabilitySuffix .question) {
3225+ blocks.add (Code ('if (${p .displayName } != null) {' ));
3226+ }
3227+ blocks.add (
3228+ refer (dataVar).property ('fields' ).property ('add' ).call ([
3229+ refer ('MapEntry' ).newInstance ([
3230+ literal (fieldName),
3231+ refer (p.displayName).property ('toIso8601String' ).call ([]),
3232+ ]),
3233+ ]).statement,
3234+ );
3235+ if (p.type.nullabilitySuffix == NullabilitySuffix .question) {
3236+ blocks.add (const Code ('}' ));
3237+ }
32333238 } else {
32343239 throw Exception ('toJson() method have to add to ${p .type }' );
32353240 }
You can’t perform that action at this time.
0 commit comments