& operator is a binary operator that performs bitwise conjunction on integer operands and non-short-circuiting logical conjunction on boolean operands.
Bitwise AND (Integers)
When applied to operands of typeint, the & operator compares each bit of the first operand to the corresponding bit of the second operand using the two’s complement binary representation. The resulting bit is set to 1 if and only if both corresponding input bits are 1; otherwise, the resulting bit is set to 0.
Syntax
Logical AND (Booleans)
When applied to operands of typebool, the & operator evaluates to true if and only if both operands are true.
Unlike the short-circuiting logical AND operator (&&), the & operator is eager. It evaluates both the left-hand side (LHS) and the right-hand side (RHS) expressions, regardless of the value of the LHS. This ensures that any side effects in the RHS expression occur even if the LHS is false.
Syntax
Operator Precedence
The& operator has higher precedence than bitwise XOR (^), bitwise OR (|), and equality operators (==, !=). It binds tighter than these operators but looser than shift operators (<<, >>).
The order of precedence for these operators is as follows (highest to lowest):
- Bitwise AND (
&) - Bitwise XOR (
^) - Bitwise OR (
|) - Relational operators (
<,>,<=,>=) - Equality (
==,!=) - Logical AND (
&&)
Master Dart with Deep Grasping Methodology!Learn More





