Open
Description
Description
The auto-generated model.dart code on Flutter does not allow setting nullable fields to null.
model = model.copyWith(nullableField: null)
Does not work.
We need an alternative like
model = model.removeKey(Model.NULLABLEFIELD)
Categories
- Analytics
- API (REST)
- API (GraphQL)
- Auth
- Authenticator
- DataStore
- Notifications (Push)
- Storage
Steps to Reproduce
Take this model:
type Model @model {
id: ID!
nullableField: String
}
This is the auto-generated Model.dart, which we use to update the model.
Model copyWith({String? nullableField}) {
return Model._internal(
id: id,
nullableField: nullableField ?? this.nullableField,
)
}
If you run:
model = model.copyWith(nullableField: null)
Your model will not change the nullableField to null.
Screenshots
No response
Platforms
- iOS
- Android
- Web
- macOS
- Windows
- Linux
Flutter Version
3.22.0
Amplify Flutter Version
1.7.0
Deployment Method
Amplify CLI
Schema
type Model @model {
id: ID!
nullableField: String
}