amplify-codegen
amplify-codegen copied to clipboard
unnecessary_non_null_assertion for `updatedAt` and `createdAt` in `toString()` from dart generator
Before opening, please confirm:
- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have searched for duplicate or closed issues.
- [X] I have read the guide for submitting bug reports.
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
How did you install the Amplify CLI?
curl
If applicable, what version of Node.js are you using?
v18.20.2
Amplify CLI Version
12.12.0
What operating system are you using?
Mac
Amplify Codegen Command
codegen models
Describe the bug
Generation of default DateTime fields for flutter creates unnecessary_non_null_assertion warning in toString() method for the exclamation marks:
buffer.write("createdAt=" + (_createdAt != null ? _createdAt!.format() : "null") + ", ");
buffer.write("updatedAt=" + (_updatedAt != null ? _updatedAt!.format() : "null"));
Expected behavior
No such warnings.
Reproduction steps
- Create any schema field in Amplify Studio
-
amplify pullin flutter project -
amplify codegen models
GraphQL schema(s)
# Put schemas below this line
type Message @model @auth(rules: [{allow: public}]) {
id: ID!
text: String
}
Log output
# Put your logs below this line
The '!' will have no effect because the receiver can't be null.
Try removing the '!' operator.
Additional information
No response