Skip to main content
The >= (greater than or equal to) operator is a relational binary operator that evaluates whether the left operand is strictly greater than or mathematically equivalent to the right operand. It evaluates the expression and returns a bool value: true if the condition is satisfied, and false otherwise.
leftOperand >= rightOperand

Technical Mechanics

In Dart, operators are instance methods. The >= operator is syntactic sugar for invoking the operator >= method on the left operand (the receiver), passing the right operand as the argument.

Built-in Types

For core numeric types (int and double, which inherit from num), the operator performs standard mathematical comparison.
bool isGreaterOrEqual = 10 >= 10; // Evaluates to true
bool isLess = 5 >= 10;            // Evaluates to false
bool isDoubleGreater = 7.5 >= 7.0; // Evaluates to true
(Note: Dart does not define relational operators like >= for String objects. Lexicographical comparison for strings must be performed using the compareTo method).

Operator Overloading

Because >= is an instance method, it can be overridden in custom classes. When defining a custom class, you must explicitly declare the operator >= method to enable the use of the >= symbol between instances of that class.
class Metric {
  final double value;

  const Metric(this.value);

  // Overriding the >= operator for custom type comparison
  bool operator >=(Metric other) {
    return this.value >= other.value;
  }
}

void main() {
  Metric m1 = Metric(100.5);
  Metric m2 = Metric(50.0);
  
  // Invokes the operator >= method on m1, passing m2 as the argument
  bool result = m1 >= m2; // Evaluates to true
}

Type Safety and Nullability

Under Dart’s sound null safety, the left operand (the receiver) must be non-null to invoke the operator method. If the left operand is null, the Dart analyzer will throw a compile-time error. The nullability of the right operand, however, depends entirely on the method signature defined by the left operand’s class. For built-in num types, the right operand must be non-null. For custom classes, a developer can explicitly define the operator >= method to accept a nullable right operand:
class TolerantMetric {
  final double value;

  const TolerantMetric(this.value);

  // The right operand is explicitly allowed to be null
  bool operator >=(TolerantMetric? other) {
    if (other == null) return true; // Custom fallback logic
    return this.value >= other.value;
  }
}
Tired of Poor Dart Skills? Fix That With Deep Grasping!Learn More