Python Core Built-In Types: int, double, num, bool, String
Dart features a clean primitive type hierarchy. All numbers inherit from the abstract `num` superclass: `int` (arbitrary precision in VM, 64-bit integers) and `double` (64-bit IEEE 754 floating point). `bool` represents strict booleans (`true` or `false`), and `String` represents UTF-16 code unit sequences.
"`num` is a parent category "Currency", while `int` is whole dollar bills and `double` is coins with decimal change."
Deep Dive: How It Works
`int` & `double`: Both inherit from `num`. You can declare `num x = 1; x = 1.5;` to accept either.
Type Conversions: `int.parse("42")`, `double.parse("3.14")`, and `value.toString()`.
Strict Boolean Logic: Unlike JS or C, non-boolean values (like `1` or `"true"`) are NOT truthy. Only the literal `true` satisfies `if` conditions.
Syntax Blueprint
int age = 30; double price = 19.99; num rating = 4.8; // Accepts int or double bool isActive = true; String code = "DART";
Core built-in type declarations in Dart.
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Using `if (userCount)` or `if (items.length)` as a boolean check.Why it happens: JavaScript and C treat non-zero integers as truthy; Dart requires explicit boolean expressions.
How to fix: Write `if (userCount > 0)` or `if (items.isNotEmpty)`.
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Parse and Calculate Average
Parse the string `"45"` to an int `a` and `"55"` to an int `b`.
Compute the double `avg = (a + b) / 2`.
Print `Average: $avg`.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.