> For the complete documentation index, see [llms.txt](https://ecm-pmdm-flutter.gitbook.io/1.-introduccion-a-flutter/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ecm-pmdm-flutter.gitbook.io/1.-introduccion-a-flutter/3.-primera-aplicacion-en-flutter/desde-el-terminal.md).

# Desde el Terminal

{% hint style="info" %}
Información oficial:

<https://flutter.dev/docs/get-started/test-drive?tab=terminal>
{% endhint %}

## **Creamos un proyecto Flutter**

1. **Abrimos** una ventana de comandos (**terminal**):
2. **Creamos** un nuevo proyecto llamado ***`myfirstapp`*** (creará el proyecto dentro del directorio ***`myfirstapp`***:

&#x20; <mark style="color:blue;">`flutter create myfirstapp`</mark>

{% hint style="danger" %}
**Atención:** La aplicación se crea por **defecto** con el nombre de **package** *com.example, y* los **lenguajes** *kotlin* y Swift, podremos especificarlos de forma explícita ( o ) añadiendo los parámetros --org, -a (para android: Java/Kotlin) y  -i (para ios: Swift/Objective-C).  Ejemplo:

<mark style="color:blue;">`$ flutter create --org dam.empar -a kotlin -i swift myfirstapp`</mark>

Para ver más información de los parámetros:  <mark style="color:blue;">`flutter create -h`</mark>
{% endhint %}

{% hint style="success" %}
**En un proyecto existente**, podremos **añadir** **plataformas desktop** deseadas (separándolas por **,** ) :&#x20;

<mark style="color:blue;">`$ flutter create --platforms=windows,macos,linux .`</mark>

Más info:  <https://docs.flutter.dev/development/platform-integration/desktop#add-desktop-support-to-an-existing-flutter-app>
{% endhint %}

3\. Para ver los **dispositivos** disponibles que tenemos en funcionamiento, ejecutaremos:&#x20;

&#x20;<mark style="color:blue;">`flutter devices`</mark>

![](/files/YXOqUQp9GkwPQ1HCmSso)

4. Para listar **AVDs (emuladores)** que tenemos disponibles, con su ID:

<mark style="color:blue;">`flutter emulators`</mark>

5. Para **arrancar** un dispositivo en el emulador por su ID:&#x20;

<mark style="color:blue;">`flutter emulators --launch <emulator_id>`</mark>

{% hint style="info" %}
También, podemos arrancar el emulador desde el SDK Android para un AVD ya creado. Por ejemplo, para abrir un AVD llamado *Pixel\_XL\_API\_31* ejecutamos:  <mark style="color:blue;">`$ ./emulator -avd Pixel_XL_API_31`</mark>
{% endhint %}

## Ejecutamos la aplicación

Cambiamos al directorio del proyecto creado y ejecutamos:

&#x20; <mark style="color:blue;">`flutter run -d <device_ID>`</mark>

{% hint style="success" %}
Por defecto, si no identificamos el dispositivo pero ya tenemos uno conectado, se ejecutará en ese dispositivo o, si no hay ninguno, se ejecutará en el navegador Chrome.
{% endhint %}

### **A. Ejecución en Android** **AVD**<mark style="background-color:orange;">:</mark>

![](/files/jJlyI4sjW2SBBF7mGRLD)

&#x20;![](/files/FhB6ltTZTiIDlNxQLAXv)

### <mark style="background-color:orange;">**B. Ejecución en**</mark> <mark style="background-color:orange;">**Chrome**</mark><mark style="background-color:orange;">:</mark>&#x20;

Cerramos/desconectamos los dispositivos y arrancamos de nuevo:

&#x20;<mark style="color:blue;">`flutter run`</mark> o también <mark style="color:blue;">`flutter run -d chrome`</mark>

![](/files/Q4FQuxEzmUfpa32M6ldY)

![](/files/TaPkmdGo1Mt6wgt5pAXi)

#### Probamos Hot restart

Durante la ejecución, si modificamos el código, y **pulsamos "R**" podremos realizar un **"hot restart"** que reiniciará la aplicación y mostrará los cambios (stop & run)

#### Profiler/DevTools

Una vez arrancada la aplicación, podemos también **abrir** la **URL** proporcionada para ver el **Profile** o abrir la URL con las **DevTools** asociadas a la aplicación en ejecución:

<figure><img src="/files/Th0eXRf6xumhrC1dyLJk" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/1pG5Vw6Se9EakuygNS0Q" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ecm-pmdm-flutter.gitbook.io/1.-introduccion-a-flutter/3.-primera-aplicacion-en-flutter/desde-el-terminal.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
