+ operator is a binary additive operator used to perform arithmetic addition on numeric operands or concatenation on string operands. In Dart, operators are instance methods with special syntax; the expression a + b is syntactic sugar for the method invocation a.+(b).
Syntax
Underlying Mechanism
Because Dart treats operators as instance methods, the behavior of+ is defined by the class of the left-hand operand. The Dart compiler resolves the operation by looking up the operator + method signature on the type of operand1.
Standard Implementations
Numeric Addition
Thenum class and its subtypes, int and double, implement operator + to perform arithmetic addition.
int+int: Returns anint.double+double: Returns adouble.- Mixed types: If one operand is a
double, the result is promoted to adouble.
String Concatenation
TheString class implements operator + to perform concatenation. This operation returns a new String object containing the sequence of code units from the left operand followed immediately by the code units from the right operand.
Operator Overloading
Custom classes can define or override the+ operator by implementing the operator + method. The method must accept a single argument (the right-hand operand) and return a result.
The following example demonstrates overloading + for vector addition:
Precedence and Associativity
The+ operator has additive precedence, which is lower than multiplicative operators (*, /, %) but higher than bitwise shift operators (<<, >>). It is left-associative, meaning expressions are evaluated from left to right.
Master Dart with Deep Grasping Methodology!Learn More





