Visualization Guide

Learn how to read and understand code visualizations

Understanding Dart Visualizations


What is Visualization?


Visualization is a graphical representation of how your code executes step-by-step. Instead of just seeing output, you can watch:

  • How variables change in memory
  • What functions are currently running (call stack)
  • The execution progress through your code

  • Why Visualizations Matter


  • **Understanding**: See exactly what happens when code runs
  • **Debugging**: Find where things go wrong
  • **Learning**: Build mental models of program flow
  • **Memory Awareness**: Understand stack vs. heap memory

  • Three Types of Visualizations


    1. Memory Display (Stack)

    Shows all variables currently in memory with their values and types.


    `

    int x = 5;

    String name = "Dart";

    `

    After running, the Memory section shows:

  • Variable names (x, name)
  • Types (int, String)
  • Current values (5, "Dart")
  • Memory addresses (location in RAM)
  • Cell2Dart
    // Run this to see Memory visualization int age = 25; double height = 5.9; String language = "Dart"; print('Age: $age'); print('Height: $height'); print('Language: $language');

    2. Call Stack (LIFO - Last In First Out)


    Shows which functions are currently running and their parameters.


    When a function is called:

  • It's pushed onto the stack
  • Shows function name and parameters
  • When it returns, it's popped off

  • The **Active** indicator shows the function currently executing.

    Cell4Dart
    // Run this to see Call Stack visualization int multiply(int a, int b) { return a * b; } int calculate(int x, int y) { int result = multiply(x, y); return result + 10; } int final_value = calculate(3, 4); print('Result: $final_value');

    3. Execution Timeline


    Shows your progress through the program with a progress bar.


  • Step counter: Which step you're on
  • Progress bar: Visual completion percentage
  • Step description: What's happening at current step

  • Reading Memory Addresses


    Memory addresses shown as `0x00000001` indicate where in RAM a variable is stored.


  • Different variables = different addresses
  • Stack memory addresses go downward
  • Heap memory addresses are separate

  • Stack vs. Heap


    **Stack Memory:**

  • Stores simple variables (int, double, String)
  • Stores references to objects
  • Limited but fast
  • Automatically cleaned up

  • **Heap Memory:**

  • Stores actual objects
  • Larger capacity
  • Slower access
  • Managed by garbage collector
  • Cell6Dart
    // Stack example int x = 10; // Stack int y = 20; // Stack int z = x + y; // Stack print('x: $x, y: $y, z: $z');

    Tips for Using Visualizations


    1. **Start Simple**: Run basic code with few variables

    2. **Watch Values Change**: See how operations modify variables

    3. **Trace Execution**: Follow the call stack through function calls

    4. **Spot Issues**: Use visualizations to find logic errors

    5. **Learn Patterns**: Understand common execution patterns

    Run code to see memory, call stack, and timeline visualizations