Don't explicitly initialize variables to null
By not explicitly assigning to null
class Dog { final id int; final String name; final int age; Dog({this.id, this.name, this.age});}
Remember, be default value of id
is set to null
. So if the consumer doesn't pass a value for id
it will continue to have null
and so will name
If you want to make any parameter mandatory then you should mark that with @required