When debugging in Flutter or even just printing out an object as a String, there is no way that I am aware of to distinguish between different instances of an object. Looking at just line 9+ or the debugger inspection how many instances of Foo do f1, f2 and f3 represent?

enter image description here

By contrast, in Java for example each instance is printed with its address and is easy to distinguish. Even if we were debugging in some code far removed from lines 5-7 it would still be easy to tell that there are two instances present.

enter image description here

I could use "evaluate expression" during debugging to check for equality manually, but this does not scale well and complicates quickly if the references are in different scopes.

Is there another solution that would work better?

Solution 1: Rémi Rousselet

What you see in the console is the toString() method.

You can override it to print some custom informations. Most flutter widgets overrides it to print their parameters for example.

A potential override would be by adding the hashcode:

String toString() {
  return super.toString() + " " + hashCode;