Returning a Function - Different Result

Hi, in the “Returning a Function” section of Dart Apprentice v1.1.0 PDF (page 123), the output of:




But mine are:


I’ve checked the code I typed several times but cannot find any typo in it. Any idea what might cause the problem (assuming it is a problem)?

By the way I am using Dartpad based on Flutter 2.2.2 Dart SDK 2.13.3 with Null Safety ON (assuming this matters).

Thank you in advance for taking the time to answer my question.

This is due to the fact that on the web (which includes DartPad) all Dart code is compiled to JavaScript. Since JavaScript does not differentiate int and double (everything is double), 42.0 is just displayed as 42. If you were to run the same code in VS Code, you would see 42.0.

I see… Thank you for your answer, much appreciated.