-=) is a compound assignment operator that subtracts the value of the right-hand operand from the variable on the left-hand side and assigns the resulting difference back to the left-hand variable.
Syntax
Operational Mechanics
- Evaluation: The expression on the right-hand side is evaluated.
- Operation: The
-operator is invoked on the current value ofvariablewith the evaluated result ofexpressionas the argument. - Assignment: The result of the subtraction is assigned to
variable.
Type Constraints
- Mutability: The variable on the left-hand side must be mutable. It cannot be declared as
finalorconst. - Type Compatibility: The type of the variable must define the subtraction operator (
operator -). Additionally, the return type of the subtraction operation must be a subtype of the variable’s declared type.
Examples
Standard Numeric Types Dart’s built-inint and double types support this operator natively.
-= operator functions on any class that overrides the - operator, provided the return type matches the variable type.
Master Dart with Deep Grasping Methodology!Learn More





