aws-amplify / aws-amplify/amplify-codegen
unnecessary_non_null_assertion for `updatedAt` and `createdAt` in `toString()` from dart generator
- Dominant language
- TypeScript
- Stars
- 59
- Forks
- 64
- PR merge metrics
- No merged PRs in 30d
Description
### 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](https://github.com/aws-amplify/amplify-codegen/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-codegen/blob/main/CONTRIBUTING.md#bugs).
- [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:
```dart
buffer.write("createdAt=" + (_createdAt != null ? _createdAt!.format() : "null") + ", ");
buffer.write("updatedAt=" + (_updatedAt != null ? _updatedAt!.format() : "null"));
```
### Expected behavior
No such warnings.
### Reproduction steps
1. Create any schema field in Amplify Studio
2. `amplify pull` in flutter project
3. `amplify codegen models`
### GraphQL schema(s)
```graphql
# 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_
Contributor guide
Assessment
This issue has not been assessed yet.