Numbers

Integers and doubles are both number types, which means that both support many of the same methods and operators. Dart numbers work pretty much like they do in many other languages.

primitives/numbers.dart
 
2 + 2; ​// 4
 
2.2 + 2; ​// 4.2
 
2 + 2.2; ​// 4.2
 
2.2 + 2.2; ​// 4.4

As you can see, Dart numbers do “the right thing” when mixing them in operations.

Get Dart 1 for Everyone now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.