{"id":515,"date":"2026-11-14T08:17:11","date_gmt":"2026-11-14T08:17:11","guid":{"rendered":"https:\/\/moiks.com\/blog\/?p=515"},"modified":"2026-11-12T08:21:00","modified_gmt":"2026-11-12T08:21:00","slug":"dart-class-modifiers-abstract-base-interface-final-sealed","status":"publish","type":"post","link":"https:\/\/moiks.com\/blog\/dart-class-modifiers-abstract-base-interface-final-sealed\/","title":{"rendered":"Dart Class Modifiers Explained: abstract, base, interface, final, sealed &#038; mixin class (2026 Guide)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Dart is an object-oriented programming language that supports classes, inheritance, interfaces, and mixins. However, as applications grow, developers need more control over how classes can be extended, implemented, or reused.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, consider these questions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Should other developers be allowed to extend a class?<\/li>\n\n\n\n<li>Should they be allowed to implement its interface without inheriting its implementation?<\/li>\n\n\n\n<li>Should a class prevent all external subtyping?<\/li>\n\n\n\n<li>Should a group of subclasses be restricted to a known set?<\/li>\n\n\n\n<li>Should reusable behavior be available through mixins?<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Dart 3 introduced class modifiers that help answer these questions directly in the language.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this comprehensive <strong>Dart class modifiers tutorial<\/strong>, we&#8217;ll explore <code>abstract<\/code>, <code>base<\/code>, <code>interface<\/code>, <code>final<\/code>, <code>sealed<\/code>, and <code>mixin class<\/code>, including their inheritance rules and practical applications.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We&#8217;ll also build a complete <strong>Flutter Notification Architecture Lab<\/strong> using modern Dart features, dependency injection, reusable behavior, and type-safe UI states.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is Article 19 of the Moiks Developer Blog Flutter Tutorials series.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What You&#8217;ll Learn<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">By the end of this tutorial, you&#8217;ll understand:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>What class modifiers are and why they matter.<\/li>\n\n\n\n<li>The difference between <code>extends<\/code>, <code>implements<\/code>, and <code>with<\/code>.<\/li>\n\n\n\n<li>How abstract classes define incomplete implementations.<\/li>\n\n\n\n<li>How base classes preserve implementation inheritance.<\/li>\n\n\n\n<li>How interface classes establish API boundaries.<\/li>\n\n\n\n<li>How final classes restrict external subtyping.<\/li>\n\n\n\n<li>How sealed classes enable exhaustive pattern matching.<\/li>\n\n\n\n<li>How mixin classes provide reusable behavior.<\/li>\n\n\n\n<li>How modifiers can be combined.<\/li>\n\n\n\n<li>How library boundaries affect inheritance rules.<\/li>\n\n\n\n<li>How to use class modifiers in real Flutter architecture.<\/li>\n\n\n\n<li>How to test class-based designs with unit and widget tests.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">1. What Are Class Modifiers in Dart?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Class modifiers are keywords that control how a class may be used or subclassed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Consider a normal Dart class:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Vehicle {\n  void start() {\n    print('Vehicle started');\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Another class can extend it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Car extends Vehicle {\n  void drive() {\n    print('Car is moving');\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A class can also implement its interface:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Bicycle implements Vehicle {\n  @override\n  void start() {\n    print('Bicycle started');\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Dart implicitly defines an interface for every class.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Without restrictive modifiers, ordinary classes can generally be extended or implemented from other libraries.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Class modifiers let API authors specify which relationships are supported.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why Class Modifiers Matter<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">They help developers:<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Protect implementation assumptions.<\/li>\n\n\n\n<li>Design stable public APIs.<\/li>\n\n\n\n<li>Reduce unintended inheritance.<\/li>\n\n\n\n<li>Create predictable class hierarchies.<\/li>\n\n\n\n<li>Express intended extension points.<\/li>\n\n\n\n<li>Enable exhaustive handling of sealed types.<\/li>\n\n\n\n<li>Improve long-term maintainability.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">These benefits become especially valuable when developing reusable Flutter packages, SDKs, and large applications.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">2. Understanding extends, implements, and with<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before exploring modifiers, we need to understand three important Dart keywords.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">extends \u2014 Inherit an Implementation<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>class Animal {\n  void eat() {\n    print('Eating');\n  }\n}\n\nclass Dog extends Animal {\n  void bark() {\n    print('Barking');\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Usage:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void main() {\n  final dog = Dog();\n\n  dog.eat();\n  dog.bark();\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>Dog<\/code> inherits the implementation of <code>eat()<\/code> from <code>Animal<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">implements \u2014 Fulfill an Interface<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>abstract interface class Storage {\n  Future&lt;void&gt; save(String value);\n}\n\nfinal class LocalStorage implements Storage {\n  @override\n  Future&lt;void&gt; save(String value) async {\n    print('Saved: $value');\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">An implementing class must provide the required interface members.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It does not inherit their method bodies through <code>implements<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">with \u2014 Apply Mixin Behavior<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>mixin Logger {\n  void log(String message) {\n    print('LOG: $message');\n  }\n}\n\nclass DataService with Logger {\n  void fetch() {\n    log('Fetching data');\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>with<\/code> keyword applies reusable mixin behavior.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Comparison<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th>Keyword<\/th><th>Purpose<\/th><th>Inherits implementation?<\/th><\/tr><tr><td><code>extends<\/code><\/td><td>Create a subclass<\/td><td>Yes<\/td><\/tr><tr><td><code>implements<\/code><\/td><td>Fulfill an interface<\/td><td>No<\/td><\/tr><tr><td><code>with<\/code><\/td><td>Apply mixin behavior<\/td><td>Yes, from the mixin<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Understanding these differences is essential for using class modifiers correctly.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">3. The abstract Modifier<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>abstract<\/code> modifier marks a class as abstract.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">An abstract class cannot be directly instantiated.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It can contain abstract members, implemented members, constructors, and fields.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>abstract class PaymentProcessor {\n  Future&lt;bool&gt; processPayment(double amount);\n\n  void printReceipt(double amount) {\n    print('Payment receipt: $amount');\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>processPayment()<\/code> method has no implementation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A concrete subclass must implement it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class CardPayment extends PaymentProcessor {\n  @override\n  Future&lt;bool&gt; processPayment(double amount) async {\n    print('Processing card payment: $amount');\n    return true;\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Usage:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Future&lt;void&gt; main() async {\n  final processor = CardPayment();\n\n  final success = await processor.processPayment(500);\n\n  if (success) {\n    processor.printReceipt(500);\n  }\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Important Rules<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Abstract classes cannot be instantiated directly.<\/li>\n\n\n\n<li>They can contain both abstract and concrete members.<\/li>\n\n\n\n<li>Concrete subclasses must satisfy inherited abstract members.<\/li>\n\n\n\n<li>A plain <code>abstract class<\/code> can generally be extended or implemented from other libraries.<\/li>\n\n\n\n<li>Abstract classes can provide shared implementations and common contracts.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">When Should You Use abstract?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use an abstract class when multiple implementations share a common contract and may also benefit from shared behavior.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Typical examples include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Repository abstractions.<\/li>\n\n\n\n<li>Payment processors.<\/li>\n\n\n\n<li>File handlers.<\/li>\n\n\n\n<li>Data converters.<\/li>\n\n\n\n<li>Authentication providers.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">4. The base Modifier<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>base<\/code> modifier restricts how a class can be subtyped outside its library.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A base class can be extended from another library, but it cannot be implemented there.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This helps preserve implementation inheritance.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>base class SecureSession {\n  bool _initialized = false;\n\n  void initialize() {\n    _initialized = true;\n  }\n\n  bool get isInitialized =&gt; _initialized;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A subclass can extend it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>final class UserSession extends SecureSession {\n  void open() {\n    initialize();\n    print('Session opened');\n  }\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Why Not implements?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Suppose a class relies on inherited implementation behavior.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Allowing unrelated external classes to implement its interface could violate assumptions made by the API author.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>base<\/code> modifier prevents external implementations that bypass the base class&#8217;s inherited behavior.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Important Rules<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A base class can be instantiated unless it is also abstract.<\/li>\n\n\n\n<li>It can be extended outside its library.<\/li>\n\n\n\n<li>It cannot be implemented outside its library.<\/li>\n\n\n\n<li>A subtype extending a base class must be marked <code>base<\/code>, <code>final<\/code>, or <code>sealed<\/code>.<\/li>\n\n\n\n<li>These restrictions are enforced across Dart library boundaries.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">When Should You Use base?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use <code>base<\/code> when subclasses must inherit implementation details that are important to the class&#8217;s behavior.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Examples include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Framework infrastructure.<\/li>\n\n\n\n<li>Stateful internal abstractions.<\/li>\n\n\n\n<li>Classes enforcing initialization behavior.<\/li>\n\n\n\n<li>SDK components with implementation invariants.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">5. The interface Modifier<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">An <code>interface class<\/code> is designed primarily to define an interface that other libraries can implement.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Outside its defining library, it can be implemented but not extended.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>abstract interface class NotificationSender {\n  Future&lt;void&gt; send(String message);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Concrete implementations can provide different behaviors.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>final class EmailSender implements NotificationSender {\n  @override\n  Future&lt;void&gt; send(String message) async {\n    print('Email: $message');\n  }\n}\n\nfinal class PushSender implements NotificationSender {\n  @override\n  Future&lt;void&gt; send(String message) async {\n    print('Push: $message');\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Usage:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Future&lt;void&gt; deliver(\n  NotificationSender sender,\n  String message,\n) async {\n  await sender.send(message);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The caller depends on the interface rather than a particular implementation.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">interface class vs abstract interface class<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">An ordinary <code>interface class<\/code> can be instantiated if it has an accessible generative constructor and is otherwise concrete.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">An <code>abstract interface class<\/code> cannot be instantiated and may declare abstract members.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For API contracts, <code>abstract interface class<\/code> is often the clearer choice.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">When Should You Use interface?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use interfaces for:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Repository contracts.<\/li>\n\n\n\n<li>API client abstractions.<\/li>\n\n\n\n<li>Analytics providers.<\/li>\n\n\n\n<li>Notification gateways.<\/li>\n\n\n\n<li>Payment integrations.<\/li>\n\n\n\n<li>Test doubles and dependency injection.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">This is particularly useful in clean architecture because implementations can be replaced without changing consumers.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">6. The final Modifier<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>final<\/code> class modifier prevents other libraries from extending or implementing a class.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It establishes a closed external subtype boundary.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>final class AppConfiguration {\n  final String appName;\n  final bool enableAnalytics;\n\n  const AppConfiguration({\n    required this.appName,\n    required this.enableAnalytics,\n  });\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Usage:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const configuration = AppConfiguration(\n  appName: 'Moiks App',\n  enableAnalytics: true,\n);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Outside the defining library, another class cannot extend or implement <code>AppConfiguration<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">final Class vs final Variable<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">These are different concepts.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>final name = 'Flutter';<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here, <code>final<\/code> prevents reassignment of the variable.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>final class AppSettings {\n  final String theme;\n\n  const AppSettings(this.theme);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here, <code>final class<\/code> restricts external subtyping.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It does not automatically make the class&#8217;s instances deeply immutable.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Important Library Detail<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A final class may still have subtypes within its own library.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Dart&#8217;s restrictions are based on libraries, not simply files or packages.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">When Should You Use final?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use final classes when an API should not support external subclassing or implementation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Examples include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Concrete service implementations.<\/li>\n\n\n\n<li>Internal value objects.<\/li>\n\n\n\n<li>Configuration models.<\/li>\n\n\n\n<li>Immutable application models.<\/li>\n\n\n\n<li>Components with closed implementation contracts.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">7. The sealed Modifier<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">A <code>sealed<\/code> class defines a hierarchy whose direct subtypes must be declared within the same library.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A sealed class is implicitly abstract.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This makes sealed classes useful for representing a known set of alternatives.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sealed class PaymentState {\n  const PaymentState();\n}\n\nfinal class PaymentIdle extends PaymentState {\n  const PaymentIdle();\n}\n\nfinal class PaymentLoading extends PaymentState {\n  const PaymentLoading();\n}\n\nfinal class PaymentSuccess extends PaymentState {\n  final String transactionId;\n\n  const PaymentSuccess(this.transactionId);\n}\n\nfinal class PaymentFailure extends PaymentState {\n  final String message;\n\n  const PaymentFailure(this.message);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now we can use a switch expression:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>String describePayment(PaymentState state) {\n  return switch (state) {\n    PaymentIdle() =&gt; 'Ready to pay',\n    PaymentLoading() =&gt; 'Processing payment',\n    PaymentSuccess(:final transactionId) =&gt;\n      'Paid: $transactionId',\n    PaymentFailure(:final message) =&gt;\n      'Failed: $message',\n  };\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Why Sealed Classes Are Powerful<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The Dart analyzer knows the direct subtype family of the sealed class.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This allows it to check whether switch expressions cover all possible cases.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If a new state is introduced, switches may need updating.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Important Nuance<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Sealed hierarchies are not necessarily limited to one inheritance level.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The exhaustiveness analysis depends on the known subtype structure and the modifiers of those subtypes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For a simple, closed hierarchy, final leaf classes are an effective design.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">When Should You Use sealed?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use sealed classes for:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Loading states.<\/li>\n\n\n\n<li>Authentication states.<\/li>\n\n\n\n<li>Payment outcomes.<\/li>\n\n\n\n<li>Search results.<\/li>\n\n\n\n<li>Form submission states.<\/li>\n\n\n\n<li>File upload states.<\/li>\n\n\n\n<li>Domain events with known variants.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">8. The mixin class Modifier<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">A <code>mixin class<\/code> can be used both as a regular class and as a mixin.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This provides flexibility for reusable behavior.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>mixin class AuditLogger {\n  void log(String message) {\n    print('&#91;AUDIT] $message');\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">It can be instantiated:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void main() {\n  final logger = AuditLogger();\n\n  logger.log('Application started');\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">It can also be applied with <code>with<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class UserService with AuditLogger {\n  void createUser(String name) {\n    log('Created user: $name');\n  }\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">mixin vs mixin class<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A declaration using <code>mixin<\/code> is intended for mixin application and cannot be directly instantiated.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A <code>mixin class<\/code> supports ordinary class usage and mixin application.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Important Restrictions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A mixin class cannot declare a generative constructor, and its superclass must be <code>Object<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">These restrictions allow its behavior to be applied safely as a mixin.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">When Should You Use mixin class?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use it for reusable, self-contained behavior such as:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Logging.<\/li>\n\n\n\n<li>Formatting.<\/li>\n\n\n\n<li>Validation helpers.<\/li>\n\n\n\n<li>Reusable calculations.<\/li>\n\n\n\n<li>Small utility capabilities.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For behavior that depends on a particular superclass or complex state initialization, a different design may be more appropriate.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">9. Other Important Class Modifier Combinations<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Dart supports useful combinations of modifiers.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">abstract interface class<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>abstract interface class UserRepository {\n  Future&lt;String&gt; getUserName();\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Use this for a contract that cannot be instantiated directly and can be implemented externally.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">abstract base class<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>abstract base class DataProcessor {\n  void process();\n\n  void logStart() {\n    print('Processing started');\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Use this when a class must be extended rather than implemented outside its library, while remaining abstract.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">abstract final class<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>abstract final class AppConstants {\n  static const appName = 'Moiks Developer Blog';\n  static const maxRetries = 3;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This combination prevents instantiation and external subtyping.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It can be useful for grouping static members, although top-level constants are often simpler.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">base mixin<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>base mixin DiagnosticBehavior {\n  void diagnose() {\n    print('Diagnostics completed');\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A base mixin places additional constraints on classes that apply it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">abstract mixin class<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>abstract mixin class Formatter {\n  String format(String value);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This can be used to define reusable mixin-compatible contracts, with concrete classes supplying required implementations.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">10. Dart Class Modifiers Comparison<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">The following table summarizes the key restrictions when the subtype is declared in a different library.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th>Modifier<\/th><th>Instantiable?<\/th><th>External <code>extends<\/code><\/th><th>External <code>implements<\/code><\/th><\/tr><tr><td><code>class<\/code><\/td><td>Yes, if concrete<\/td><td>Yes<\/td><td>Yes<\/td><\/tr><tr><td><code>abstract class<\/code><\/td><td>No<\/td><td>Yes<\/td><td>Yes<\/td><\/tr><tr><td><code>base class<\/code><\/td><td>Yes, if concrete<\/td><td>Yes<\/td><td>No<\/td><\/tr><tr><td><code>interface class<\/code><\/td><td>Yes, if concrete<\/td><td>No<\/td><td>Yes<\/td><\/tr><tr><td><code>final class<\/code><\/td><td>Yes, if concrete<\/td><td>No<\/td><td>No<\/td><\/tr><tr><td><code>sealed class<\/code><\/td><td>No<\/td><td>No<\/td><td>No<\/td><\/tr><tr><td><code>mixin class<\/code><\/td><td>Yes, if concrete<\/td><td>Yes<\/td><td>Yes<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">A <code>mixin class<\/code> can additionally be applied using <code>with<\/code>, subject to mixin-related restrictions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The exact rules for combined modifiers depend on the combination.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Library Boundaries Matter<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In Dart, a library is the relevant unit for many class modifier restrictions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Two files imported into each other are not automatically part of the same library.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A declaration using <code>part<\/code> belongs to its parent library, but most Flutter projects are better organized around separate imported libraries.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This distinction matters when designing public APIs and testing inheritance restrictions.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">11. Choosing the Right Modifier<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Use the following decision guide.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th>Requirement<\/th><th>Recommended declaration<\/th><\/tr><tr><td>Shared incomplete implementation<\/td><td><code>abstract class<\/code><\/td><\/tr><tr><td>Must inherit implementation<\/td><td><code>base class<\/code><\/td><\/tr><tr><td>External implementations allowed<\/td><td><code>abstract interface class<\/code><\/td><\/tr><tr><td>No external subtyping<\/td><td><code>final class<\/code><\/td><\/tr><tr><td>Exhaustive family of alternatives<\/td><td><code>sealed class<\/code><\/td><\/tr><tr><td>Reusable behavior usable as class or mixin<\/td><td><code>mixin class<\/code><\/td><\/tr><tr><td>Abstract contract requiring implementation inheritance<\/td><td><code>abstract base class<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">There is no universally best modifier.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The correct choice depends on the API&#8217;s intended extension and implementation behavior.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">12. Practical Flutter Project: Notification Architecture Lab<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Now we&#8217;ll build a complete Flutter application demonstrating these concepts together.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The application will simulate sending notifications through different channels.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Users can select Email, Push, or SMS, enter a message, and send it through a simulated gateway.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The interface displays idle, loading, success, and failure states.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Features<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Material 3 user interface.<\/li>\n\n\n\n<li>Email, Push, and SMS notification channels.<\/li>\n\n\n\n<li>Dependency injection through an interface.<\/li>\n\n\n\n<li>Simulated asynchronous delivery.<\/li>\n\n\n\n<li>Custom error handling.<\/li>\n\n\n\n<li>Sealed UI state hierarchy.<\/li>\n\n\n\n<li>Exhaustive switch expression rendering.<\/li>\n\n\n\n<li>Reusable audit logging.<\/li>\n\n\n\n<li>Message validation.<\/li>\n\n\n\n<li>Retry after failure.<\/li>\n\n\n\n<li>Unit and widget tests.<\/li>\n\n\n\n<li>No external packages or backend required.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">How Each Modifier Is Used<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th>Modifier<\/th><th>Project component<\/th><\/tr><tr><td><code>abstract interface class<\/code><\/td><td><code>NotificationGateway<\/code><\/td><\/tr><tr><td><code>base class<\/code><\/td><td><code>MessageTemplate<\/code><\/td><\/tr><tr><td><code>final class<\/code><\/td><td><code>NotificationMessage<\/code>, gateway and controller<\/td><\/tr><tr><td><code>sealed class<\/code><\/td><td><code>DeliveryState<\/code><\/td><\/tr><tr><td><code>mixin class<\/code><\/td><td><code>AuditLogger<\/code><\/td><\/tr><tr><td><code>abstract<\/code><\/td><td>Gateway and template contracts<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Create the Project<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>flutter create dart_class_modifiers_demo\ncd dart_class_modifiers_demo<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Use the standard Flutter SDK dependencies generated by <code>flutter create<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Project Structure<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>lib\/\n\u251c\u2500\u2500 main.dart\n\u251c\u2500\u2500 models\/\n\u2502   \u2514\u2500\u2500 notification_message.dart\n\u251c\u2500\u2500 services\/\n\u2502   \u251c\u2500\u2500 notification_gateway.dart\n\u2502   \u2514\u2500\u2500 message_template.dart\n\u251c\u2500\u2500 state\/\n\u2502   \u251c\u2500\u2500 delivery_state.dart\n\u2502   \u2514\u2500\u2500 notification_controller.dart\n\u2514\u2500\u2500 widgets\/\n    \u2514\u2500\u2500 delivery_result_card.dart\n\ntest\/\n\u251c\u2500\u2500 notification_controller_test.dart\n\u251c\u2500\u2500 notification_gateway_test.dart\n\u2514\u2500\u2500 widget_test.dart<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">13. Create the Notification Model<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Create <code>lib\/models\/notification_message.dart<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>enum NotificationChannel {\n  email,\n  push,\n  sms,\n}\n\nextension NotificationChannelInfo\n    on NotificationChannel {\n  String get label =&gt; switch (this) {\n    NotificationChannel.email =&gt; 'Email',\n    NotificationChannel.push =&gt; 'Push',\n    NotificationChannel.sms =&gt; 'SMS',\n  };\n}\n\nfinal class NotificationMessage {\n  final String id;\n  final NotificationChannel channel;\n  final String content;\n\n  const NotificationMessage({\n    required this.id,\n    required this.channel,\n    required this.content,\n  });\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Why final class?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>NotificationMessage<\/code> is a concrete data model.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The project does not require external classes to extend or implement it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using <code>final class<\/code> communicates that this is not an intended extension point.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The fields are also declared <code>final<\/code> and the constructor is <code>const<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">These choices provide immutable field bindings, although a final class modifier alone does not guarantee immutability.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">14. Create an Abstract Interface for Delivery<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Create <code>lib\/services\/notification_gateway.dart<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import '..\/models\/notification_message.dart';\n\nabstract interface class NotificationGateway {\n  Future&lt;String&gt; send(\n    NotificationMessage message,\n  );\n}\n\nfinal class FakeNotificationGateway\n    implements NotificationGateway {\n  final Duration delay;\n  final bool shouldFail;\n\n  const FakeNotificationGateway({\n    this.delay = const Duration(\n      milliseconds: 500,\n    ),\n    this.shouldFail = false,\n  });\n\n  @override\n  Future&lt;String&gt; send(\n    NotificationMessage message,\n  ) async {\n    await Future&lt;void&gt;.delayed(delay);\n\n    if (shouldFail) {\n      throw StateError(\n        'Simulated notification delivery failure',\n      );\n    }\n\n    if (message.content.trim().isEmpty) {\n      throw ArgumentError(\n        'Notification message cannot be empty',\n      );\n    }\n\n    return 'DELIVERED-${message.id}';\n  }\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Why abstract interface class?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The UI and controller should not depend directly on a particular delivery implementation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A future production application could implement:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>final class FirebaseNotificationGateway\n    implements NotificationGateway {\n  @override\n  Future&lt;String&gt; send(\n    NotificationMessage message,\n  ) async {\n    \/\/ Integrate an authorized delivery backend.\n    throw UnimplementedError();\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The example above illustrates the contract only; it is not part of the runnable project.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A real push, SMS, or email service would require an appropriate backend or provider.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Benefits<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The interface makes it possible to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Replace implementations.<\/li>\n\n\n\n<li>Write deterministic tests.<\/li>\n\n\n\n<li>Introduce different delivery providers.<\/li>\n\n\n\n<li>Keep business logic independent of network libraries.<\/li>\n\n\n\n<li>Apply dependency inversion.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">15. Create a Base Message Template<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Create <code>lib\/services\/message_template.dart<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>base class MessageTemplate {\n  String format(String content) {\n    return content.trim();\n  }\n}\n\nfinal class EmailMessageTemplate\n    extends MessageTemplate {\n  @override\n  String format(String content) {\n    return 'Hello,\\n\\n${super.format(content)}'\n        '\\n\\nRegards,\\nMoiks Studio';\n  }\n}\n\nfinal class SmsMessageTemplate\n    extends MessageTemplate {\n  @override\n  String format(String content) {\n    return super.format(content);\n  }\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Why base class?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>MessageTemplate<\/code> provides a shared implementation of <code>format()<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Subclasses inherit that implementation and may extend it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>base<\/code> modifier ensures external subclasses inherit the base implementation rather than merely implementing its interface.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Notice that the subclasses are declared <code>final<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This satisfies the rules for subtypes of base classes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Practical Benefit<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This design is useful when common behavior must remain available to subclasses.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For a simple formatting-only application, composition could also be an appropriate alternative.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">16. Create Sealed Delivery States<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Create <code>lib\/state\/delivery_state.dart<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sealed class DeliveryState {\n  const DeliveryState();\n}\n\nfinal class DeliveryIdle extends DeliveryState {\n  const DeliveryIdle();\n}\n\nfinal class DeliverySending extends DeliveryState {\n  const DeliverySending();\n}\n\nfinal class DeliverySuccess extends DeliveryState {\n  final String receiptId;\n\n  const DeliverySuccess(this.receiptId);\n}\n\nfinal class DeliveryFailure extends DeliveryState {\n  final String message;\n\n  const DeliveryFailure(this.message);\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Why sealed class?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The screen has four meaningful states.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DeliveryState\n    |\n    +-- DeliveryIdle\n    |\n    +-- DeliverySending\n    |\n    +-- DeliverySuccess\n    |\n    +-- DeliveryFailure<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A sealed hierarchy makes these states explicit.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It also enables exhaustive switch expressions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If a new state is introduced later, the analyzer can help identify places where handling must be updated.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">17. Create a Reusable Audit Logger<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">We will use <code>mixin class<\/code> for logging behavior.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Create <code>lib\/state\/notification_controller.dart<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import 'package:flutter\/foundation.dart';\n\nimport '..\/models\/notification_message.dart';\nimport '..\/services\/notification_gateway.dart';\nimport 'delivery_state.dart';\n\nmixin class AuditLogger {\n  void log(String message) {\n    debugPrint('&#91;Notification Audit] $message');\n  }\n}\n\nfinal class NotificationController\n    extends ChangeNotifier\n    with AuditLogger {\n  final NotificationGateway gateway;\n\n  DeliveryState _state = const DeliveryIdle();\n  bool _disposed = false;\n  int _requestCounter = 0;\n\n  NotificationController({\n    required this.gateway,\n  });\n\n  DeliveryState get state =&gt; _state;\n\n  bool get isSending =&gt; _state is DeliverySending;\n\n  Future&lt;void&gt; send({\n    required NotificationChannel channel,\n    required String content,\n  }) async {\n    if (_disposed || isSending) return;\n\n    final trimmed = content.trim();\n\n    if (trimmed.isEmpty) {\n      _update(\n        const DeliveryFailure(\n          'Please enter a notification message.',\n        ),\n      );\n      return;\n    }\n\n    _update(const DeliverySending());\n\n    final message = NotificationMessage(\n      id: (++_requestCounter).toString(),\n      channel: channel,\n      content: trimmed,\n    );\n\n    try {\n      log('Sending ${channel.label} notification');\n\n      final receiptId = await gateway.send(message);\n\n      if (_disposed) return;\n\n      log('Delivery completed: $receiptId');\n\n      _update(DeliverySuccess(receiptId));\n    } catch (error, stackTrace) {\n      if (_disposed) return;\n\n      log('Delivery failed: $error');\n      debugPrintStack(stackTrace: stackTrace);\n\n      _update(\n        const DeliveryFailure(\n          'Unable to send notification. '\n          'Please try again.',\n        ),\n      );\n    }\n  }\n\n  void reset() {\n    if (_disposed || isSending) return;\n\n    _update(const DeliveryIdle());\n  }\n\n  void _update(DeliveryState newState) {\n    if (_disposed) return;\n\n    _state = newState;\n    notifyListeners();\n  }\n\n  @override\n  void dispose() {\n    _disposed = true;\n    super.dispose();\n  }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Understanding the Controller<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This class demonstrates several important concepts.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">final class<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>final class NotificationController<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The controller is a concrete implementation not intended for external subtyping.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">extends<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>extends ChangeNotifier<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The controller inherits Flutter&#8217;s notification mechanism.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">with<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>with AuditLogger<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The controller reuses audit logging behavior.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Dependency Injection<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>final NotificationGateway gateway;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The controller depends on an interface.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This allows tests to supply a fake gateway.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sealed State<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>DeliveryState _state = const DeliveryIdle();<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The controller exposes one structured state rather than several unrelated Boolean flags.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Lifecycle Handling<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>_disposed<\/code> flag prevents asynchronous completions from notifying listeners after disposal.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For production applications, cancellation should also be implemented when the underlying operation supports it.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">18. Create the Delivery Result Widget<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Create <code>lib\/widgets\/delivery_result_card.dart<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import 'package:flutter\/material.dart';\n\nimport '..\/state\/delivery_state.dart';\n\nclass DeliveryResultCard extends StatelessWidget {\n  final DeliveryState state;\n  final VoidCallback onRetry;\n\n  const DeliveryResultCard({\n    super.key,\n    required this.state,\n    required this.onRetry,\n  });\n\n  @override\n  Widget build(BuildContext context) {\n    return switch (state) {\n      DeliveryIdle() =&gt; const Card(\n          child: Padding(\n            padding: EdgeInsets.all(24),\n            child: Center(\n              child: Text(\n                'Choose a channel and send a message.',\n                textAlign: TextAlign.center,\n              ),\n            ),\n          ),\n        ),\n\n      DeliverySending() =&gt; const Card(\n          child: Padding(\n            padding: EdgeInsets.all(24),\n            child: Column(\n              children: &#91;\n                CircularProgressIndicator(),\n                SizedBox(height: 12),\n                Text('Sending notification...'),\n              ],\n            ),\n          ),\n        ),\n\n      DeliverySuccess(:final receiptId) =&gt; Card(\n          child: Padding(\n            padding: const EdgeInsets.all(24),\n            child: Column(\n              children: &#91;\n                const Icon(\n                  Icons.check_circle_outline,\n                  color: Colors.green,\n                  size: 48,\n                ),\n                const SizedBox(height: 12),\n                const Text(\n                  'Notification Delivered',\n                  style: TextStyle(\n                    fontWeight: FontWeight.bold,\n                    fontSize: 18,\n                  ),\n                ),\n                const SizedBox(height: 8),\n                Text('Receipt: $receiptId'),\n              ],\n            ),\n          ),\n        ),\n\n      DeliveryFailure(:final message) =&gt; Card(\n          child: Padding(\n            padding: const EdgeInsets.all(24),\n            child: Column(\n              children: &#91;\n                const Icon(\n                  Icons.error_outline,\n                  color: Colors.red,\n                  size: 48,\n                ),\n                const SizedBox(height: 12),\n                Text(\n                  message,\n                  textAlign: TextAlign.center,\n                ),\n                const SizedBox(height: 16),\n                FilledButton.icon(\n                  onPressed: onRetry,\n                  icon: const Icon(Icons.refresh),\n                  label: const Text('Retry'),\n                ),\n              ],\n            ),\n          ),\n        ),\n    };\n  }\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Exhaustive Switch Expression<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The widget handles all four <code>DeliveryState<\/code> subclasses.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Notice that there is no wildcard <code>_<\/code> case.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is intentional.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If another direct state subtype is added, Dart&#8217;s exhaustiveness checking can help identify missing handling.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Object Patterns<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The expression:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DeliverySuccess(:final receiptId)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">extracts the <code>receiptId<\/code> property from a matching <code>DeliverySuccess<\/code> object.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This combines the sealed class concept with the object patterns covered in Article 18.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">19. Build the Flutter Application<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>lib\/main.dart<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import 'package:flutter\/material.dart';\n\nimport 'models\/notification_message.dart';\nimport 'services\/message_template.dart';\nimport 'services\/notification_gateway.dart';\nimport 'state\/notification_controller.dart';\nimport 'widgets\/delivery_result_card.dart';\n\nvoid main() {\n  runApp(const NotificationLabApp());\n}\n\nclass NotificationLabApp extends StatelessWidget {\n  final NotificationGateway gateway;\n\n  const NotificationLabApp({\n    super.key,\n    this.gateway = const FakeNotificationGateway(),\n  });\n\n  @override\n  Widget build(BuildContext context) {\n    return MaterialApp(\n      title: 'Notification Architecture Lab',\n      debugShowCheckedModeBanner: false,\n      theme: ThemeData(\n        colorScheme: ColorScheme.fromSeed(\n          seedColor: const Color(0xFF004B64),\n        ),\n        useMaterial3: true,\n      ),\n      home: NotificationLabScreen(\n        gateway: gateway,\n      ),\n    );\n  }\n}\n\nclass NotificationLabScreen extends StatefulWidget {\n  final NotificationGateway gateway;\n\n  const NotificationLabScreen({\n    super.key,\n    required this.gateway,\n  });\n\n  @override\n  State&lt;NotificationLabScreen&gt; createState() =&gt;\n      _NotificationLabScreenState();\n}\n\nclass _NotificationLabScreenState\n    extends State&lt;NotificationLabScreen&gt; {\n  late final NotificationController controller;\n\n  final messageController = TextEditingController(\n    text: 'Welcome to Moiks Developer Blog!',\n  );\n\n  NotificationChannel selectedChannel =\n      NotificationChannel.email;\n\n  bool simulateFailure = false;\n\n  @override\n  void initState() {\n    super.initState();\n\n    controller = NotificationController(\n      gateway: widget.gateway,\n    );\n  }\n\n  String formatMessage(String content) {\n    return switch (selectedChannel) {\n      NotificationChannel.email =&gt;\n        EmailMessageTemplate().format(content),\n\n      NotificationChannel.push =&gt;\n        MessageTemplate().format(content),\n\n      NotificationChannel.sms =&gt;\n        SmsMessageTemplate().format(content),\n    };\n  }\n\n  Future&lt;void&gt; sendMessage() async {\n    final content = formatMessage(\n      messageController.text,\n    );\n\n    if (simulateFailure) {\n      final failingController = NotificationController(\n        gateway: const FakeNotificationGateway(\n          shouldFail: true,\n          delay: Duration(milliseconds: 300),\n        ),\n      );\n\n      \/\/ Use the main controller's state handling\n      \/\/ for the normal application workflow.\n      failingController.dispose();\n\n      \/\/ The simulated failure is represented by\n      \/\/ the selected gateway in the app-level tests.\n      \/\/ For this UI demo, show a validation failure.\n      await controller.send(\n        channel: selectedChannel,\n        content: '',\n      );\n      return;\n    }\n\n    await controller.send(\n      channel: selectedChannel,\n      content: content,\n    );\n  }\n\n  @override\n  void dispose() {\n    messageController.dispose();\n    controller.dispose();\n    super.dispose();\n  }\n\n  @override\n  Widget build(BuildContext context) {\n    return Scaffold(\n      appBar: AppBar(\n        title: const Text(\n          'Notification Architecture Lab',\n        ),\n        centerTitle: true,\n      ),\n      body: SafeArea(\n        child: Center(\n          child: ConstrainedBox(\n            constraints: const BoxConstraints(\n              maxWidth: 720,\n            ),\n            child: ListView(\n              padding: const EdgeInsets.all(16),\n              children: &#91;\n                Card(\n                  child: Padding(\n                    padding: const EdgeInsets.all(20),\n                    child: Column(\n                      children: &#91;\n                        const Icon(\n                          Icons.notifications_active_outlined,\n                          size: 52,\n                          color: Color(0xFF004B64),\n                        ),\n                        const SizedBox(height: 12),\n                        Text(\n                          'Dart Class Modifiers',\n                          style: Theme.of(context)\n                              .textTheme\n                              .headlineSmall,\n                        ),\n                        const SizedBox(height: 8),\n                        const Text(\n                          'Explore interfaces, base classes, '\n                          'sealed states and reusable mixins.',\n                          textAlign: TextAlign.center,\n                        ),\n                      ],\n                    ),\n                  ),\n                ),\n\n                const SizedBox(height: 20),\n\n                DropdownButtonFormField&lt;\n                    NotificationChannel&gt;(\n                  initialValue: selectedChannel,\n                  decoration: const InputDecoration(\n                    labelText: 'Notification Channel',\n                    border: OutlineInputBorder(),\n                  ),\n                  items: &#91;\n                    for (final channel\n                        in NotificationChannel.values)\n                      DropdownMenuItem(\n                        value: channel,\n                        child: Text(channel.label),\n                      ),\n                  ],\n                  onChanged: (channel) {\n                    if (channel == null ||\n                        controller.isSending) {\n                      return;\n                    }\n\n                    setState(() {\n                      selectedChannel = channel;\n                    });\n\n                    controller.reset();\n                  },\n                ),\n\n                const SizedBox(height: 16),\n\n                TextField(\n                  controller: messageController,\n                  maxLines: 4,\n                  decoration: const InputDecoration(\n                    labelText: 'Message',\n                    hintText: 'Enter notification message',\n                    border: OutlineInputBorder(),\n                  ),\n                ),\n\n                const SizedBox(height: 12),\n\n                SwitchListTile(\n                  title: const Text(\n                    'Simulate Failure',\n                  ),\n                  subtitle: const Text(\n                    'Show the error handling state',\n                  ),\n                  value: simulateFailure,\n                  onChanged: (value) {\n                    if (controller.isSending) return;\n\n                    setState(() {\n                      simulateFailure = value;\n                    });\n\n                    controller.reset();\n                  },\n                ),\n\n                const SizedBox(height: 16),\n\n                AnimatedBuilder(\n                  animation: controller,\n                  builder: (context, child) {\n                    return Column(\n                      children: &#91;\n                        SizedBox(\n                          width: double.infinity,\n                          child: FilledButton.icon(\n                            onPressed: controller.isSending\n                                ? null\n                                : sendMessage,\n                            icon: const Icon(Icons.send),\n                            label: const Text(\n                              'Send Notification',\n                            ),\n                          ),\n                        ),\n\n                        const SizedBox(height: 20),\n\n                        DeliveryResultCard(\n                          state: controller.state,\n                          onRetry: sendMessage,\n                        ),\n                      ],\n                    );\n                  },\n                ),\n              ],\n            ),\n          ),\n        ),\n      ),\n    );\n  }\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">What the Application Demonstrates<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The screen provides a simple interface for sending simulated notifications.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The selected channel determines how the message is formatted.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The controller manages asynchronous delivery and exposes a sealed UI state.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The result widget uses exhaustive pattern matching to render the appropriate content.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The notification gateway can be replaced with a different implementation without changing the controller.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Important Note About Simulated Failure<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The sample UI&#8217;s <strong>Simulate Failure<\/strong> switch demonstrates a failure state using an empty-message validation path. The gateway&#8217;s <code>shouldFail<\/code> option separately supports simulated asynchronous delivery failures and is covered in the tests below.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In a production implementation, a dedicated configurable fake gateway or injected failure strategy would provide a more faithful simulation of network failures.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">20. Understanding the Architecture<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">The completed project follows this structure:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Flutter Notification Lab\n          |\n          v\nNotificationLabScreen\n          |\n          v\nNotificationController\n          |\n          +---- AuditLogger\n          |\n          v\nNotificationGateway\n          |\n          v\nFakeNotificationGateway\n          |\n          v\nNotificationMessage\n\nController State\n          |\n          v\nDeliveryState (sealed)\n          |\n          +---- DeliveryIdle\n          +---- DeliverySending\n          +---- DeliverySuccess\n          +---- DeliveryFailure\n          |\n          v\nDeliveryResultCard<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Dependency Inversion<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The controller depends on <code>NotificationGateway<\/code>, not <code>FakeNotificationGateway<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is an example of dependency inversion.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Reusable Behavior<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>AuditLogger<\/code> supplies logging functionality through a mixin class.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Closed UI State Hierarchy<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>DeliveryState<\/code> provides a known set of states that the UI can handle exhaustively.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Implementation Inheritance<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>MessageTemplate<\/code> provides common formatting behavior inherited by specialized templates.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Together, these patterns demonstrate how class modifiers help communicate architectural intent.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">21. Unit Testing the Notification Gateway<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Create <code>test\/notification_gateway_test.dart<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import 'package:flutter_test\/flutter_test.dart';\n\nimport 'package:dart_class_modifiers_demo\/models\/notification_message.dart';\nimport 'package:dart_class_modifiers_demo\/services\/notification_gateway.dart';\n\nvoid main() {\n  const message = NotificationMessage(\n    id: '101',\n    channel: NotificationChannel.email,\n    content: 'Hello Flutter',\n  );\n\n  test('Returns receipt on success', () async {\n    const gateway = FakeNotificationGateway(\n      delay: Duration.zero,\n    );\n\n    final receipt = await gateway.send(message);\n\n    expect(receipt, 'DELIVERED-101');\n  });\n\n  test('Throws on simulated failure', () async {\n    const gateway = FakeNotificationGateway(\n      delay: Duration.zero,\n      shouldFail: true,\n    );\n\n    await expectLater(\n      gateway.send(message),\n      throwsStateError,\n    );\n  });\n\n  test('Rejects empty message', () async {\n    const gateway = FakeNotificationGateway(\n      delay: Duration.zero,\n    );\n\n    const emptyMessage = NotificationMessage(\n      id: '102',\n      channel: NotificationChannel.push,\n      content: ' ',\n    );\n\n    await expectLater(\n      gateway.send(emptyMessage),\n      throwsArgumentError,\n    );\n  });\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">These tests verify the gateway contract&#8217;s success and failure behavior.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">22. Unit Testing the Controller<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Create <code>test\/notification_controller_test.dart<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import 'package:flutter_test\/flutter_test.dart';\n\nimport 'package:dart_class_modifiers_demo\/models\/notification_message.dart';\nimport 'package:dart_class_modifiers_demo\/services\/notification_gateway.dart';\nimport 'package:dart_class_modifiers_demo\/state\/delivery_state.dart';\nimport 'package:dart_class_modifiers_demo\/state\/notification_controller.dart';\n\nvoid main() {\n  test('Starts in idle state', () {\n    final controller = NotificationController(\n      gateway: const FakeNotificationGateway(\n        delay: Duration.zero,\n      ),\n    );\n\n    expect(controller.state, isA&lt;DeliveryIdle&gt;());\n\n    controller.dispose();\n  });\n\n  test('Moves to success after delivery', () async {\n    final controller = NotificationController(\n      gateway: const FakeNotificationGateway(\n        delay: Duration.zero,\n      ),\n    );\n\n    await controller.send(\n      channel: NotificationChannel.email,\n      content: 'Hello',\n    );\n\n    expect(controller.state, isA&lt;DeliverySuccess&gt;());\n\n    final state = controller.state as DeliverySuccess;\n\n    expect(state.receiptId, 'DELIVERED-1');\n\n    controller.dispose();\n  });\n\n  test('Rejects empty message', () async {\n    final controller = NotificationController(\n      gateway: const FakeNotificationGateway(\n        delay: Duration.zero,\n      ),\n    );\n\n    await controller.send(\n      channel: NotificationChannel.sms,\n      content: ' ',\n    );\n\n    expect(controller.state, isA&lt;DeliveryFailure&gt;());\n\n    controller.dispose();\n  });\n\n  test('Handles gateway failure', () async {\n    final controller = NotificationController(\n      gateway: const FakeNotificationGateway(\n        delay: Duration.zero,\n        shouldFail: true,\n      ),\n    );\n\n    await controller.send(\n      channel: NotificationChannel.push,\n      content: 'Test message',\n    );\n\n    expect(controller.state, isA&lt;DeliveryFailure&gt;());\n\n    controller.dispose();\n  });\n\n  test('Can reset to idle', () async {\n    final controller = NotificationController(\n      gateway: const FakeNotificationGateway(\n        delay: Duration.zero,\n      ),\n    );\n\n    await controller.send(\n      channel: NotificationChannel.email,\n      content: 'Hello',\n    );\n\n    controller.reset();\n\n    expect(controller.state, isA&lt;DeliveryIdle&gt;());\n\n    controller.dispose();\n  });\n\n  test('Notifies listeners on state changes', () async {\n    final controller = NotificationController(\n      gateway: const FakeNotificationGateway(\n        delay: Duration.zero,\n      ),\n    );\n\n    var notifications = 0;\n\n    controller.addListener(() {\n      notifications++;\n    });\n\n    await controller.send(\n      channel: NotificationChannel.email,\n      content: 'Hello',\n    );\n\n    expect(notifications, 2);\n\n    controller.dispose();\n  });\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">What These Tests Cover<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Initial state.<\/li>\n\n\n\n<li>Successful delivery.<\/li>\n\n\n\n<li>Input validation.<\/li>\n\n\n\n<li>Gateway failure.<\/li>\n\n\n\n<li>State reset.<\/li>\n\n\n\n<li>ChangeNotifier updates.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The controller can be tested without launching a Flutter screen.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is a major advantage of dependency injection and interface-based design.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">23. Flutter Widget Testing<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Create <code>test\/widget_test.dart<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import 'package:flutter\/material.dart';\nimport 'package:flutter_test\/flutter_test.dart';\n\nimport 'package:dart_class_modifiers_demo\/main.dart';\nimport 'package:dart_class_modifiers_demo\/services\/notification_gateway.dart';\n\nvoid main() {\n  testWidgets('Displays application title', (tester) async {\n    await tester.pumpWidget(\n      const NotificationLabApp(),\n    );\n\n    expect(\n      find.text('Notification Architecture Lab'),\n      findsOneWidget,\n    );\n\n    expect(\n      find.text('Dart Class Modifiers'),\n      findsOneWidget,\n    );\n  });\n\n  testWidgets('Displays channel selector', (tester) async {\n    await tester.pumpWidget(\n      const NotificationLabApp(),\n    );\n\n    expect(\n      find.byType(DropdownButtonFormField),\n      findsOneWidget,\n    );\n  });\n\n  testWidgets('Displays successful delivery', (tester) async {\n    await tester.pumpWidget(\n      const NotificationLabApp(\n        gateway: FakeNotificationGateway(\n          delay: Duration.zero,\n        ),\n      ),\n    );\n\n    await tester.tap(\n      find.text('Send Notification'),\n    );\n\n    await tester.pumpAndSettle();\n\n    expect(\n      find.text('Notification Delivered'),\n      findsOneWidget,\n    );\n  });\n\n  testWidgets('Displays delivery failure', (tester) async {\n    await tester.pumpWidget(\n      const NotificationLabApp(\n        gateway: FakeNotificationGateway(\n          delay: Duration.zero,\n          shouldFail: true,\n        ),\n      ),\n    );\n\n    await tester.tap(\n      find.text('Send Notification'),\n    );\n\n    await tester.pumpAndSettle();\n\n    expect(\n      find.textContaining('Unable to send'),\n      findsOneWidget,\n    );\n\n    expect(\n      find.text('Retry'),\n      findsOneWidget,\n    );\n  });\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Run the Tests<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>flutter test<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Run Static Analysis<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>flutter analyze<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Run the Application<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>flutter run<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The project uses only Flutter SDK libraries.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">No third-party dependency is required.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">24. Class Modifiers and Clean Architecture<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Class modifiers can make architectural boundaries clearer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Consider a typical Flutter application:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Presentation Layer\n    |\n    v\nApplication Layer\n    |\n    v\nDomain Layer\n    |\n    v\nData Layer<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Domain Contracts<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use <code>abstract interface class<\/code> for contracts implemented by infrastructure components.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>abstract interface class ProductRepository {\n  Future&lt;List&lt;String&gt;&gt; fetchProducts();\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Concrete Implementations<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use <code>final class<\/code> for concrete implementations that are not intended to be subclassed.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>final class InMemoryProductRepository\n    implements ProductRepository {\n  @override\n  Future&lt;List&lt;String&gt;&gt; fetchProducts() async {\n    return &#91;'Phone', 'Laptop', 'Tablet'];\n  }\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Shared Infrastructure<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use <code>base class<\/code> when external subclasses must inherit shared implementation behavior.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Application States<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use <code>sealed class<\/code> for finite state hierarchies.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Reusable Behavior<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use <code>mixin<\/code> or <code>mixin class<\/code> for carefully designed reusable functionality.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">These choices help communicate which parts of an application are stable contracts and which are implementation details.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">25. Class Modifiers vs SOLID Principles<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Class modifiers complement object-oriented design principles.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Single Responsibility Principle<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A class should have a focused responsibility.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Modifiers do not enforce this automatically, but clear class boundaries can support it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Open\/Closed Principle<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Interfaces and carefully designed base classes provide intentional extension points.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Final classes communicate that external subtyping is not supported.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Liskov Substitution Principle<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Base classes can preserve inherited behavior, but developers must still ensure that subclasses respect the expected contracts.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Interface Segregation Principle<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Small interfaces help consumers depend only on capabilities they need.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Dependency Inversion Principle<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">High-level application logic should depend on abstractions rather than concrete infrastructure implementations.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Our <code>NotificationController<\/code> demonstrates this by depending on <code>NotificationGateway<\/code>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">26. Common Mistakes with Dart Class Modifiers<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">Mistake 1: Confusing final Class with Immutable Objects<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A final class is not automatically immutable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use final fields, appropriate constructors, and immutable data structures when immutability is required.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Mistake 2: Using base When External Implementations Are Needed<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A base class cannot be implemented outside its library.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If consumers must supply their own implementations, consider an interface.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Mistake 3: Using interface When Inherited Behavior Is Required<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">An interface class allows external implementation but prevents external extension.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If inherited behavior is essential, consider a base class.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Mistake 4: Using sealed for Open Extension Points<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A sealed class restricts direct subtyping to its library.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is not appropriate when arbitrary external implementations should be supported.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Mistake 5: Assuming sealed Means Every Subclass Is final<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Subclasses can have their own permitted modifiers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Choose final leaf types when you want a straightforward closed hierarchy.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Mistake 6: Overusing Abstract Classes<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Not every class needs an abstraction.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Introduce interfaces where they provide a real architectural benefit.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Mistake 7: Creating Large Mixins<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Mixins should generally contain focused reusable behavior.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Large mixins with hidden dependencies can become difficult to maintain.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Mistake 8: Ignoring Library Boundaries<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Modifier restrictions apply across library boundaries.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A class in a different imported Dart file generally belongs to another library.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Mistake 9: Using Inheritance Instead of Composition<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Inheritance is useful, but composition is often simpler when behavior does not require an is-a relationship.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Mistake 10: Using Wildcard Cases for Every Sealed Switch<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A wildcard fallback can hide missing cases.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Prefer explicit exhaustive handling when modeling a closed state hierarchy.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">27. Best Practices for Production Flutter Applications<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Follow these recommendations:<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Use <code>abstract interface class<\/code> for public contracts that need multiple implementations.<\/li>\n\n\n\n<li>Use <code>final class<\/code> for concrete types that should not be externally subtyped.<\/li>\n\n\n\n<li>Use <code>base class<\/code> when inherited implementation behavior must be preserved.<\/li>\n\n\n\n<li>Use <code>sealed class<\/code> for finite state hierarchies.<\/li>\n\n\n\n<li>Prefer final leaf classes for straightforward sealed-state designs.<\/li>\n\n\n\n<li>Use <code>mixin class<\/code> only when both class usage and mixin application are genuinely useful.<\/li>\n\n\n\n<li>Keep reusable mixin behavior focused.<\/li>\n\n\n\n<li>Avoid creating interfaces without a clear reason.<\/li>\n\n\n\n<li>Document intended extension points in public APIs.<\/li>\n\n\n\n<li>Prefer composition over inheritance when it produces simpler designs.<\/li>\n\n\n\n<li>Write unit tests against interfaces and application behavior.<\/li>\n\n\n\n<li>Use exhaustive switches to detect missing state handling.<\/li>\n\n\n\n<li>Keep implementation details separate from domain contracts.<\/li>\n\n\n\n<li>Review library boundaries when designing reusable Dart packages.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">The goal is not to use every modifier in every project.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The goal is to make class relationships intentional, understandable, and maintainable.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">28. Frequently Asked Questions<\/h1>\n\n\n\n<h3 class=\"wp-block-heading\">1. What are class modifiers in Dart?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Class modifiers are keywords that control how classes can be instantiated, extended, implemented, or used as mixins.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. When were Dart class modifiers introduced?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The modern class modifier system was introduced with Dart 3.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. What is an abstract class in Dart?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">An abstract class cannot be instantiated directly and may contain abstract and concrete members.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. What is a base class in Dart?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A base class can be extended outside its library but cannot be implemented there.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. What is an interface class?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">An interface class allows external implementations but prevents external extension.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">6. What is an abstract interface class?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">It is an abstract class intended to define a contract that external classes may implement.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">7. What is a final class?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A final class prevents external classes from extending or implementing it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">8. Does final class mean immutable?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. It controls external subtyping, not object mutability.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">9. What is a sealed class?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A sealed class restricts direct subtyping to its own library and supports exhaustive subtype analysis.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">10. Why are sealed classes useful in Flutter?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">They are useful for representing a finite set of application states and handling them with exhaustive switches.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">11. What is a mixin class?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A mixin class can be used as a regular class and applied as a mixin.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">12. What is the difference between mixin and mixin class?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A mixin is intended for mixin application, while a mixin class can additionally be used as a class.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">13. What is the difference between extends and implements?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>extends<\/code> inherits implementation, while <code>implements<\/code> requires the implementing class to fulfill an interface.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">14. What does with mean in Dart?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>with<\/code> keyword applies reusable mixin behavior to a class.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">15. Can a base class be instantiated?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes, if it is concrete and has an accessible constructor.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">16. Can a sealed class be instantiated?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. A sealed class is implicitly abstract.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">17. Can a final class have subclasses?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes, within its own library. External subtyping is restricted.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">18. Can an interface class contain implemented methods?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. However, external implementers do not inherit those method implementations through <code>implements<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">19. What is an abstract base class?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">It is an abstract class that requires external subclasses to inherit its implementation rather than merely implement its interface.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">20. What is an abstract final class?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">It combines non-instantiability with restrictions on external subtyping.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">21. Can I combine class modifiers?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes, Dart supports certain valid modifier combinations.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">22. Are class modifiers required in Flutter?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. They are optional language features, but they can improve API design and maintainability.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">23. Should repositories use interface classes?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Repository contracts often benefit from <code>abstract interface class<\/code>, particularly when multiple implementations or test doubles are required.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">24. Should Flutter state classes be sealed?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Sealed classes are a good choice for a finite set of distinct states, but they are not mandatory for every state-management design.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">25. Do class modifiers improve performance?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Their primary purpose is API design and type safety. Performance improvements should not be assumed without measurement.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">26. Can class modifiers prevent every inheritance-related bug?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. They enforce structural restrictions but do not replace good design, validation, and testing.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">27. Are class modifiers useful for SDK development?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. They allow SDK authors to communicate and enforce supported extension points.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">28. What is the best class modifier for a concrete service?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A final class is often appropriate when external subtyping is not intended.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">29. What is the best modifier for reusable behavior?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A mixin or mixin class may be suitable, depending on whether class instantiation is also required.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">30. Are Dart class modifiers production-ready?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. They are established Dart 3 language features used in modern Dart and Flutter development.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">29. Conclusion<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Dart class modifiers provide developers with greater control over object-oriented design.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>abstract<\/code> modifier defines classes that cannot be directly instantiated.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>base<\/code> modifier ensures external subclasses inherit implementation behavior.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>interface<\/code> modifier establishes contracts that external classes can implement.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>final<\/code> modifier prevents external subtyping.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>sealed<\/code> modifier defines known subtype families that support exhaustive pattern matching.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>mixin class<\/code> declaration allows reusable behavior to be used both as a class and as a mixin.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this tutorial, we explored each modifier and built a practical Flutter Notification Architecture Lab.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The application demonstrated interface-based dependency injection, base-class inheritance, final concrete implementations, sealed UI states, reusable audit logging, asynchronous delivery handling, and automated testing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The key takeaway is to choose class modifiers based on the relationships your API should support\u2014not simply to make your code look more advanced.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Well-designed class boundaries make Flutter applications easier to test, extend, and maintain.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s Next in the Flutter Tutorials Series?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Flutter Article 20: Dart Callable Classes, Factory Constructors &amp; Redirecting Constructors Explained (2026 Guide)<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the next tutorial, we&#8217;ll explore callable objects, named and factory constructors, redirecting constructors, constructor initialization, object creation patterns, and practical Flutter architecture examples.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Continue learning Flutter and Dart on <strong>Moiks Developer Blog<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-embed\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/moiks.com\/blog\n<\/div><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Official Documentation and References<\/h2>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Dart Class Modifiers \u2014 <a href=\"https:\/\/dart.dev\/language\/class-modifiers\" target=\"_blank\" rel=\"noopener\">https:\/\/dart.dev\/language\/class-modifiers<\/a><\/li>\n\n\n\n<li>Dart Class Modifiers for API Maintainers \u2014 <a href=\"https:\/\/dart.dev\/language\/class-modifiers-for-apis\" target=\"_blank\" rel=\"noopener\">https:\/\/dart.dev\/language\/class-modifiers-for-apis<\/a><\/li>\n\n\n\n<li>Dart Classes \u2014 <a href=\"https:\/\/dart.dev\/language\/classes\" target=\"_blank\" rel=\"noopener\">https:\/\/dart.dev\/language\/classes<\/a><\/li>\n\n\n\n<li>Dart Constructors \u2014 <a href=\"https:\/\/dart.dev\/language\/constructors\" target=\"_blank\" rel=\"noopener\">https:\/\/dart.dev\/language\/constructors<\/a><\/li>\n\n\n\n<li>Dart Mixins \u2014 <a href=\"https:\/\/dart.dev\/language\/mixins\" target=\"_blank\" rel=\"noopener\">https:\/\/dart.dev\/language\/mixins<\/a><\/li>\n\n\n\n<li>Dart Patterns \u2014 <a href=\"https:\/\/dart.dev\/language\/patterns\" target=\"_blank\" rel=\"noopener\">https:\/\/dart.dev\/language\/patterns<\/a><\/li>\n\n\n\n<li>Dart Branches and Switch Expressions \u2014 <a href=\"https:\/\/dart.dev\/language\/branches\" target=\"_blank\" rel=\"noopener\">https:\/\/dart.dev\/language\/branches<\/a><\/li>\n\n\n\n<li>Flutter App Architecture \u2014 <a href=\"https:\/\/docs.flutter.dev\/app-architecture\" target=\"_blank\" rel=\"noopener\">https:\/\/docs.flutter.dev\/app-architecture<\/a><\/li>\n\n\n\n<li>Flutter Testing Overview \u2014 <a href=\"https:\/\/docs.flutter.dev\/testing\/overview\" target=\"_blank\" rel=\"noopener\">https:\/\/docs.flutter.dev\/testing\/overview<\/a><\/li>\n\n\n\n<li>Flutter ChangeNotifier API \u2014 <a href=\"https:\/\/api.flutter.dev\/flutter\/foundation\/ChangeNotifier-class.html\" target=\"_blank\" rel=\"noopener\">https:\/\/api.flutter.dev\/flutter\/foundation\/ChangeNotifier-class.html<\/a><\/li>\n\n\n\n<li>DartPad \u2014 <a href=\"https:\/\/dartpad.dev\/\" target=\"_blank\" rel=\"noopener\">https:\/\/dartpad.dev\/<\/a><\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Moiks Developer Blog \u2014 Practical Flutter, Dart, Android, and iOS development tutorials.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn Dart 3 class modifiers with practical examples covering abstract, base, interface, final, sealed, and mixin class. Understand extends, implements, with, and inheritance restrictions while building a complete Flutter Notification Architecture Lab with type-safe states, reusable services, and automated unit and widget tests.<\/p>\n","protected":false},"author":1,"featured_media":516,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":0,"footnotes":""},"categories":[353,397],"tags":[410,576,579,575,580,448,578,454,432,577,369],"class_list":["post-515","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-flutter-tutorials","category-dart-programming","tag-dart-3","tag-dart-abstract-class","tag-dart-base-class","tag-dart-class-modifiers","tag-dart-final-class","tag-dart-inheritance","tag-dart-interface-class","tag-dart-mixin-class","tag-dart-oop","tag-dart-sealed-class","tag-flutter-architecture"],"_links":{"self":[{"href":"https:\/\/moiks.com\/blog\/wp-json\/wp\/v2\/posts\/515","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/moiks.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/moiks.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/moiks.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/moiks.com\/blog\/wp-json\/wp\/v2\/comments?post=515"}],"version-history":[{"count":1,"href":"https:\/\/moiks.com\/blog\/wp-json\/wp\/v2\/posts\/515\/revisions"}],"predecessor-version":[{"id":517,"href":"https:\/\/moiks.com\/blog\/wp-json\/wp\/v2\/posts\/515\/revisions\/517"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/moiks.com\/blog\/wp-json\/wp\/v2\/media\/516"}],"wp:attachment":[{"href":"https:\/\/moiks.com\/blog\/wp-json\/wp\/v2\/media?parent=515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/moiks.com\/blog\/wp-json\/wp\/v2\/categories?post=515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/moiks.com\/blog\/wp-json\/wp\/v2\/tags?post=515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}