In this class I dont want to (chatCard.person) named constructor has subtitle property.Because I dont need it.But as you can see I have this error :All final variables must be initialized, but ‘subtitle’ isn’t.
Try adding an initializer for the field.
I know that If I remove final keyWord from its definition in third line the error will remove But then the class isnt immutable.
So any idea?
2
Answers
You can use a factory constructor that doesn’t include the
subtitle
property:You can follow like