0

In Java we know to create sealed class. If we use final with class no one can extend this class. In Dart there is no any option. we can extend every class. If we extend every class so how we cannot extend Dart built in classes?

  • 2
    I've never really understood why classes need to be sealed. If you're worried someone will extend your class and break the functionality, that's on them, not on you. – Abion47 Nov 02 '21 at 17:38
  • That really depends on your relation with the people who might extend your classes, and what might go wrong if they do. If someone extends your class, you can't change it in a way which breaks their subclass (q.v. fragile subclass). If those people are important customers, you might not just be able to break them, even if it's their fault, and you're effectively prevented from doing what you want with your own class. If it's your own developers doing it, it hurts you too. Preventing extension keeps your options open. – lrn Nov 03 '21 at 10:42

0 Answers0