> (greater than) operator is a binary relational operator that evaluates whether the value of the left-hand operand is strictly greater than the value of the right-hand operand. It returns a bool result: true if the condition is met, and false otherwise.
Syntax
Underlying Mechanism
In Dart, operators are instance methods with special syntax. The expressiona > b is syntactic sugar that resolves to the invocation of the instance method defined as operator > on the left operand a, passing b as the argument.
While the syntax a > b looks like a primitive operation, it strictly adheres to method dispatch rules, meaning the behavior is determined entirely by the class definition of the left-hand operand.
Standard Implementation
The corenum type (and its subtypes int and double) implements this operator to perform numeric comparison.
Operator Overloading
Custom classes can define the behavior of the> operator by implementing the operator > method. The method must accept one argument (the right-hand operand) and conventionally returns a bool.
Constraints
- Null Safety: Neither operand can be
nullunless the operator implementation explicitly accepts a nullable type. Attempting to use>on a nullable receiver without a null check will cause a compile-time error. - Type Compatibility: The right-hand operand must be of a type accepted by the left-hand operand’s
operator >method signature. Mismatched types will result in a static analysis error or a runtimeTypeError. - Associativity: The
>operator is non-associative. Expressions likea > b > care invalid becausea > bevaluates to abool, andbooldoes not define a>operator.
Master Dart with Deep Grasping Methodology!Learn More





