> ## 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.

# Function Parameters

> Learn how to pass parameters to functions in Dart

## Introduction

Parameters allow you to pass data into functions, making them more flexible and reusable. Instead of working with fixed values, functions can process different inputs.

## Basic Parameter Syntax

Define parameters inside the parentheses with their type and name:

```dart theme={null}
int operacion(int valorUno, int valorDos) {
  int suma = valorUno + valorDos;
  return suma;
}
```

### Key Components

* **Parameter type**: `int` - specifies what type of data the parameter accepts
* **Parameter name**: `valorUno`, `valorDos` - names used to reference the values inside the function
* **Multiple parameters**: Separated by commas

## Passing Arguments

When calling a function, provide values (arguments) for each parameter:

```dart theme={null}
int resultado = operacion(21, 35);
print('El Resultado es: $resultado');
// Output: El Resultado es: 56
```

<Note>
  **Arguments** are the actual values you pass when calling a function, while **parameters** are the variables that receive those values in the function definition.
</Note>

## Different Ways to Use Parameters

### Store Result in Variable

```dart theme={null}
int resultado = operacion(21, 35);
print('\nEl Resultado es: $resultado');
// Output: El Resultado es: 56
```

### Direct String Interpolation

```dart theme={null}
print('\nEl Resultado es: ${operacion(7, 3)}');
// Output: El Resultado es: 10
```

### Direct Print

```dart theme={null}
print(operacion(20, 2));
// Output: 22
```

## Complete Example

```dart theme={null}
int operacion(int valorUno, int valorDos){
  int suma = valorUno + valorDos;
  return suma;
}

void main() {
  int resultado = operacion(21, 35);
  print('\nEl Resultado es: $resultado');

  //Otra manera de usar es:
  print('\nEl Resultado es: ${operacion(7, 3)}');

  //De otra forma más:
  print(operacion(20, 2));
}
```

## Parameter Order

<Warning>
  Positional parameters must be provided in the exact order they are defined. The first argument matches the first parameter, the second argument matches the second parameter, and so on.
</Warning>

```dart theme={null}
int operacion(int valorUno, int valorDos) {
  return valorUno - valorDos;
}

void main() {
  print(operacion(10, 5));  // 10 - 5 = 5
  print(operacion(5, 10));  // 5 - 10 = -5
}
```

## Multiple Parameter Types

Functions can accept parameters of different types:

```dart theme={null}
void mostrarPersona(String nombre, int edad, double altura) {
  print('Nombre: $nombre');
  print('Edad: $edad años');
  print('Altura: $altura m');
}

void main() {
  mostrarPersona('Juan', 25, 1.75);
}
```

## Parameter Examples by Type

<CardGroup cols={2}>
  <Card title="Numeric Parameters" icon="calculator">
    ```dart theme={null}
    double calcularPromedio(double a, double b) {
      return (a + b) / 2;
    }
    ```
  </Card>

  <Card title="String Parameters" icon="quote-right">
    ```dart theme={null}
    String concatenar(String a, String b) {
      return '$a $b';
    }
    ```
  </Card>

  <Card title="Boolean Parameters" icon="circle-check">
    ```dart theme={null}
    void verificar(bool esValido) {
      print(esValido ? 'Válido' : 'Inválido');
    }
    ```
  </Card>

  <Card title="Mixed Parameters" icon="layer-group">
    ```dart theme={null}
    void registrar(String nombre, int id, bool activo) {
      print('$nombre (#$id): $activo');
    }
    ```
  </Card>
</CardGroup>

## Best Practices

<Tip>
  * Use descriptive parameter names that indicate their purpose
  * Limit the number of parameters (ideally 3 or fewer)
  * Order parameters from most to least important
  * Consider using named parameters for functions with many parameters
</Tip>

<Check>
  * Always specify parameter types for better code clarity
  * Ensure arguments match the expected parameter types
  * Document complex parameter requirements
</Check>
