In the implementation, Contact class is a “contract” which means that it is only used to retrieve and store information (e.g. by parsing the JSON or XML and storing the result in List<Contact>). In the code, we are only representing this data (read-only), we do not manipulate it or change it in any way, hence we can make the fields (properties) of Contact objects as final, also provide a const constructor. Since the final field could only be set once, we are ensuring that the information stored in the Contact class won’t be changed, the class is immutable. That optimizes the code a little bit, also it becomes clear just by looking at this class that the field values won’t change over time.
I hope I have answered your question. For more info: https://dart.dev/guides/language/language-tour#final-and-const

Written by

Software Engineer @ Devbridge | Flutter Enthusiast https://www.linkedin.com/in/mangirdas-kazlauskas/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store