> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/NormandoRamirezDelgado/6C-Febrero-2026/llms.txt
> Use this file to discover all available pages before exploring further.

# Data Types

> Explore Dart fundamental data types: int, double, String, bool, and dynamic

## Introduction

Dart is a **statically typed** language, which means every variable has a type. Understanding data types is essential for working effectively with Dart. This guide covers the five fundamental data types you'll use most often.

## The Five Core Data Types

<CardGroup cols={2}>
  <Card title="int" icon="hashtag">
    Integer numbers (whole numbers without decimals)
  </Card>

  <Card title="double" icon="1">
    Decimal numbers (floating-point numbers)
  </Card>

  <Card title="String" icon="font">
    Text and character sequences
  </Card>

  <Card title="bool" icon="toggle-on">
    Boolean values (true or false)
  </Card>

  <Card title="dynamic" icon="shuffle">
    Dynamic type (can change at runtime)
  </Card>
</CardGroup>

## int - Integer Numbers

The `int` type represents whole numbers without decimal points. They can be positive, negative, or zero.

```dart theme={null}
void main() {
  // int: Whole numbers
  int numero = 10;
  int edad = 18;
  int entero = -1223343553445632345;
  
  print(numero);  // 10
  print(edad);    // 18
  print(entero);  // -1223343553445632345
}
```

<Note>
  In Dart, integers can be very large. The exact range depends on the platform, but Dart handles large numbers efficiently.
</Note>

## double - Decimal Numbers

The `double` type represents floating-point numbers (numbers with decimal points).

```dart theme={null}
void main() {
  // double: Decimal numbers
  double promedio = 9.4;
  double valor = 0.50;
  double numeroDos = 19.0;
  double doble = 1265464764675476465456.2342121216571321315215341345234532453;
  
  print(promedio);   // 9.4
  print(numeroDos);  // 19.0
  print(valor);      // 0.5
  print(doble);      // 1.2654647646754765e+21
}
```

<Tip>
  Even if a number doesn't have a fractional part (like `19.0`), including the decimal point makes it a `double` rather than an `int`.
</Tip>

## String - Text Data

The `String` type represents sequences of characters (text). Strings are enclosed in either single quotes `'...'` or double quotes `"..."`.

```dart theme={null}
void main() {
  // String: Text sequences
  String cadena = 'Cualquier texto es valido entre comillas';
  String sexo = 'Masculino';
  String numeroCadena = '56';  // This is a STRING, not a number!
  String espacio = ' ';
  String nulo = '';            // Empty string
  
  print(cadena);        // Cualquier texto es valido entre comillas
  print(sexo);          // Masculino
  print(nulo);          // (empty)
  print(espacio);       // (space)
  print(numeroCadena);  // 56
}
```

<Warning>
  `'56'` is a String, not a number. You cannot perform mathematical operations on it without first converting it to a number.
</Warning>

### String Characteristics

* Can contain any characters: letters, numbers, symbols, spaces
* Can be empty: `''`
* Enclosed in single `'...'` or double `"..."` quotes
* Numbers in quotes are treated as text, not numeric values

## bool - Boolean Values

The `bool` type represents logical values: `true` or `false`. Booleans are essential for conditional logic and decision-making in programs.

```dart theme={null}
void main() {
  // bool: True or False values
  bool esEstudiante = true;
  bool esMayorEdad = false;
  
  print(esEstudiante);  // true
  print(esMayorEdad);   // false
}
```

<Note>
  Boolean values are always lowercase in Dart: `true` and `false` (not `True` or `FALSE`).
</Note>

## dynamic - Dynamic Type

The `dynamic` type is special - it can hold any type of value and can change its type at runtime.

```dart theme={null}
void main() {
  // dynamic: Can change type at runtime
  dynamic valorDinamico = 10;                      // int
  valorDinamico = 'Puedo cambiar a String';       // now String
  valorDinamico = false;                          // now bool
  valorDinamico = 8.3;                            // now double
  
  print(valorDinamico);  // 8.3
  
  valorDinamico = 'Hola';
  print(valorDinamico);  // Hola
}
```

<Warning>
  Use `dynamic` sparingly! While flexible, it bypasses Dart's type safety and can lead to runtime errors. Prefer specific types when possible.
</Warning>

### When to Use dynamic

* Working with data from external sources where the type isn't known at compile time
* Interfacing with JavaScript or other dynamic languages
* Handling JSON data before parsing

<Tip>
  In most cases, you should prefer specific types (`int`, `String`, etc.) over `dynamic` to leverage Dart's type safety features.
</Tip>

## Complete Example

Here's a comprehensive example using all five data types:

```dart theme={null}
void main() {
  // Integer
  int edad = 25;
  
  // Double
  double salario = 45000.50;
  
  // String
  String nombre = 'Ana García';
  
  // Boolean
  bool esEmpleado = true;
  
  // Dynamic
  dynamic informacionExtra = 'Departamento: IT';
  
  // Display employee information
  print('Nombre: $nombre');
  print('Edad: $edad');
  print('Salario: \$${salario}');
  print('Es empleado: $esEmpleado');
  print(informacionExtra);
  
  // Dynamic can change
  informacionExtra = 5;  // Now it's a number
  print('Años de experiencia: $informacionExtra');
}
```

## Type Summary Table

| Type      | Description     | Example Values                     |
| --------- | --------------- | ---------------------------------- |
| `int`     | Whole numbers   | `10`, `-5`, `0`, `1000000`         |
| `double`  | Decimal numbers | `3.14`, `0.5`, `19.0`, `-2.5`      |
| `String`  | Text            | `'Hello'`, `"Dart"`, `'123'`, `''` |
| `bool`    | Boolean         | `true`, `false`                    |
| `dynamic` | Any type        | Can be any of the above            |

## Key Takeaways

* **int**: Use for counting, indexing, and whole number calculations
* **double**: Use for measurements, percentages, and precise calculations
* **String**: Use for text, names, messages, and character data
* **bool**: Use for flags, conditions, and true/false states
* **dynamic**: Use sparingly when type is truly unknown at compile time

## Next Steps

Now that you understand Dart's basic data types, you're ready to learn about constants and how to create values that never change.
