@@ -519,9 +519,9 @@ class in a single library.
519
519
520
520
## Classes and mixins
521
521
522
- Classes . But Dart does not require all code to be defined inside a
522
+ classes . But Dart does not require all code to be defined inside a
523
523
class—you can define top-level variables, constants, and functions like
524
- you can in a procedural or functional language
524
+ you can in a procedural or functional language.
525
525
526
526
### AVOID defining a one-member abstract class when a simple function will do
527
527
@@ -622,22 +622,20 @@ Otherwise, later changes to it may break your code.
622
622
623
623
### DO use class modifiers to control if your class can be extended
624
624
625
- Class modifiers like ` final ` , ` base ` , or ` sealed `
626
- allow you to enforce whether a class can be extended directly in code.
625
+ Class modifiers like ` final ` , ` base ` , or ` sealed `
626
+ enforce whether a class can be extended.
627
627
For example, use ` final class A {} ` to prevent extension,
628
- or ` base class B {} ` to allow extension only within the same library.
629
- Rely on these modifiers rather than documentation to communicate and
630
- enforce your intent.
628
+ or ` base class B {} ` to allow extension only within the same library.
629
+ Use these modifiers to communicate your intent, rather than relying on documentation.
631
630
632
631
633
- ### ### DO use class modifiers to control if your class can be an interface
634
-
635
- you can also restrict implementation using
636
- ` final ` , ` base ` , or ` interface ` . For example, ` final class C {} `
637
- prevents implementation, while ` interface class D {} ` allows it explicitly.
638
- Use these modifiers to enforce your design intent instead of relying solely
639
- on documentation.
632
+ ### DO use class modifiers to control if your class can be an interface
640
633
634
+ When designing a library, use class modifiers like ` final ` , ` base ` , or ` interface ` to enforce intended
635
+ usage. For example, ` final class C {} ` prevents implementation, while ` interface class D {} `
636
+ explicitly allows it. While it's ideal for all libraries to use these modifiers to enforce design intent,
637
+ developers may still encounter cases where they aren't applied. In such cases, be mindful of
638
+ unintended implementation issues.
641
639
642
640
<a id =" do-use-mixin-to-define-a-mixin-type " ></a >
643
641
<a id =" avoid-mixing-in-a-class-that-isnt-intended-to-be-a-mixin " ></a >
0 commit comments