aws-amplify / amplify-codegen

Amplify Codegen is a JavaScript toolkit library for frontend and mobile developers building Amplify applications.
Apache License 2.0
59 stars 59 forks source link

unnecessary_non_null_assertion for `updatedAt` and `createdAt` in `toString()` from dart generator #839

Open koromkorom opened 4 months ago

koromkorom commented 4 months ago

Before opening, please confirm:

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

  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