Classes in Dart are not dramatically different from what you would find in other object-oriented programming (OOP) languages. The main differences have more to do with what is missing rather than what has been added. Dart can fully support most OOP paradigms, but it can also do so without a large number of keywords. Here are a few examples of some common keywords that are generally associated with OOP that are not available in Dart:
- private
- protected
- public
- struct
- interface
- protocol
It may take a while to let go of using these, especially for longtime adherents of OOP, but you don't need any of these keywords and you can still write type-safe encapsulated, object-oriented code.
In this recipe, we're going to define a class hierarchy around formal and informal names.