Skip to main content
The > (greater than) operator is a relational binary operator that evaluates whether the left operand is strictly greater in value than the right operand. It yields a bool result (true or false).
leftOperand > rightOperand

Technical Specifications

  • Return Type: bool
  • Default Operands: The core implementation applies to the num class, encompassing both int and double types.
  • Precedence: Relational precedence. It evaluates after arithmetic operators (e.g., +, *) but before equality (==, !=) and logical operators (&&, ||).
  • Associativity: None (Non-associative). Relational operators cannot be chained. An expression such as a > b > c is syntactically invalid in Dart.

Operator Overloading

Because Dart treats operators as instance methods, the > operator is syntactic sugar for a method call. Invoking a > b is structurally equivalent to calling a.operator >(b). Consequently, this operator can be overridden in custom classes to define domain-specific comparison logic.
class Metric {
  final int value;

  Metric(this.value);

  // Overriding the > operator
  bool operator >(Metric other) {
    return this.value > other.value;
  }
}

Type Coercion in Numerics

When comparing mixed numeric types (e.g., an int and a double), Dart implicitly handles type coercion at the VM level, treating both operands as num during the evaluation without requiring explicit casting.
int integerValue = 10;
double doubleValue = 9.5;

// Valid comparison across num subtypes
bool result = integerValue > doubleValue; 
Tired of Poor Dart Skills? Fix That With Deep Grasping!Learn More