ADocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
base mixin class in Dart is a compound class modifier that defines a construct capable of being instantiated, extended, or mixed in, while strictly prohibiting external implementation. By applying the base modifier, it guarantees that all subtypes inherit the actual implementation of the class rather than just its interface, enforcing a closed implementation hierarchy outside its defining library.
Syntax
Core Mechanics and Restrictions
The behavior of abase mixin class is the intersection of the rules governing base, mixin, and class modifiers:
- Inheritance Restrictions (
mixin class): Amixin classcannot have anextendsclause or awithclause. It must directly extendObject. It is structurally forbidden from inheriting from other classes or mixing in other mixins. - Instantiation and Constructors (
class/mixin class): It can be instantiated directly, provided it is not markedabstract. However, because it acts as amixin class, it cannot declare any constructors whatsoever. This prohibition applies to both generative constructors (including an explicit empty default constructor likeName();) andfactoryconstructors. It must rely entirely on the implicit default constructor. - Extension (
base/class): It can be extended using theextendskeyword from any library. - Mixing (
mixin): It can be mixed into other classes using thewithkeyword from any library. It cannot declare anonclause because it is declared as aclass. - Implementation Restriction (
base): It cannot be implemented using theimplementskeyword outside of the library in which it is defined. - Subtype Enforcement (
base): The modifier propagation (or subtype restriction) rule applies to all subtypes. Any declaration that becomes a subtype—whether by extending (extends), mixing in (with), implementing (implements, which is only allowed in the defining library), or using it as a mixin constraint (on)—must explicitly declare a modifier that preserves the base restriction. Subtype classes must be markedbase,final, orsealed, and subtype mixins must be markedbase.
Structural Rules Visualization
To understand the enforcement boundaries and structural limitations, consider the following cross-library interaction.library_a.dart (Defining Library)
library_b.dart (Consuming Library)
Modifier Compatibility
abstract: Abase mixin classcan be prefixed withabstract(abstract base mixin class). This removes the ability to instantiate it directly while retaining the extension, mixing, and base implementation rules.- Mutually Exclusive Modifiers: It cannot be combined with
interface,final, orsealed, as Dart enforces a single access-control modifier per class declaration.
Master Dart with Deep Grasping Methodology!Learn More





