class Robot { static final Robot _instance = new Robot._(7); final double height; factory Robot() { return _instance; } Robot._(this.height); } void main() { var r1 = Robot(); var r2 = Robot(); print(identical(r1, r2)); // true print(r1 == r2); // true }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter