-
Notifications
You must be signed in to change notification settings - Fork 34
Non nullable fields
Ravi Teja Gudapati edited this page May 31, 2018
·
11 revisions
Non-nullable field shall be excluded during serialization, if its value is null.
class Player {
String name;
int age;
Player({this.name, this.age});
}
playerSerializer.to(Player(name: 'Lejard'));
If field age
is nullable, the above code would print:
{name: Lejard, age: null}
If age
is configured to be nullable, the above code would print:
{name: Lejard}
Notice how the non-nullable field age
is skipped when its value is null
.
All fields are nullable by default.
{{ TODO msg="How to make a field non-nullable" }}