.) is a primary syntactic mechanism used for member access, method invocation, and namespace resolution. It establishes a relationship between a left-hand operand (the receiver or scope) and a right-hand operand (the identifier) to retrieve values or invoke behavior.
Syntax
Instance Member Access and Resolution
When the left-hand operand is an expression evaluating to an object instance, the dot operator resolves the identifier based on the static type of the receiver.- Interface Resolution: The compiler first attempts to resolve the identifier as a member (field, getter, setter, or method) defined in the interface of the receiver’s static type.
- Extension Resolution: If the member is not found in the type definition, the compiler checks for applicable extension members (methods, getters, setters, or operators) available in the current scope that match the receiver’s static type.
- Dynamic Dispatch: If the static type is
dynamic, member resolution is deferred until runtime.
Static Member and Constructor Access
When the left-hand operand is a type identifier (referencing a class, mixin, or enum directly), the dot operator accesses static members or named constructors associated with that type. This differs from a type literal (which evaluates to aType object) and allows access to the namespace of the type definition itself.
Library Prefix Access
When a library is imported with a prefix using theas keyword, the dot operator resolves symbols within that library’s namespace. In this context, the left-hand operand is the library prefix, and the right-hand operand is a top-level definition (such as a class, variable, or function).
Nullability and Object Members
Dart’s sound null safety restricts the use of the standard dot operator on nullable types.- Members of
Object: The operator is permitted on a nullable receiver only if the identifier corresponds to a member defined onObject(toString,hashCode,runtimeType). - Other Members: Accessing any other member on a nullable receiver results in a compile-time error, requiring the use of the null-aware operator (
?.) or null assertion (!).
Operator Precedence and Associativity
The dot operator belongs to the highest precedence tier in Dart (postfix operators). It shares this precedence level with(), [], ?[], ++, and --.
Operators in this tier are left-associative. When multiple operators of this tier appear in sequence, they are evaluated from left to right.
Master Dart with Deep Grasping Methodology!Learn More





