~/= operator is the compound assignment operator for truncating division. It divides the variable on the left-hand side by the operand on the right-hand side, discards any fractional component of the quotient (truncates towards zero), and assigns the resulting int back to the left-hand variable.
Syntax
Operational Equivalence
The expressiona ~/= b is semantically equivalent to:
Technical Behavior
- Integer Result: The operation always produces an
int. It floors positive results and ceils negative results (rounds towards zero). - Type Constraints:
- Right-hand side (Divisor): Can be of type
intordouble. - Left-hand side (Variable): Must be a type compatible with an
intassignment (e.g.,int,num, ordynamic). - Incompatibility: Because the result is strictly an
int, this operator cannot be used on variables explicitly typed asdouble. Dart does not perform implicit casting frominttodoubleduring variable assignment.
- Right-hand side (Divisor): Can be of type
Examples
Master Dart with Deep Grasping Methodology!Learn More





