operator == method

  1. @nonVirtual
  2. @override
bool operator ==(
  1. Object other
)
override

Compare two components for equality.

When a component is rebuilt with another that compares equal according to operator ==, it is assumed that the update is redundant and the work to update that branch of the tree is skipped.

It is generally discouraged to override operator == on any component that has children, since a correct implementation would have to defer to the children's equality operator also, and that is an O(N²) operation: each child would need to itself walk all its children, each step of the tree.

It is sometimes reasonable for a leaf component (one with no children) to implement this method, if rebuilding the component is known to be much more expensive than checking the components' parameters for equality and if the component is expected to often be rebuilt with identical parameters.

In general, however, it is more efficient to cache the components used in a build method if it is known that they will not change.

Implementation

@nonVirtual
@override
// ignore: avoid_equals_and_hash_code_on_mutable_classes
bool operator ==(Object other) => identical(this, other);