How to run First Flutter Application ?

To run your first Flutter application, follow these steps:

  1. Create a new Flutter project:

    • Open a Command Prompt or Terminal window.
    • Navigate to the directory where you want to create your Flutter project.
    • Run the command flutter create my_app (replace "my_app" with your desired project name).
    • This command will generate a new Flutter project with the necessary files and directories.
  2. Navigate to the project directory:

    • In the Command Prompt or Terminal, navigate to the directory of your newly created Flutter project using the cd command. For example, cd my_app.
  3. Connect a device or start an emulator:

    • Connect a physical device (e.g., Android phone) to your computer via USB, or start an emulator (e.g., Android Virtual Device).
    • Ensure that USB debugging is enabled on your device or emulator.
  4. Run the application:

    • In the Command Prompt or Terminal, run the command flutter run.
    • Flutter will compile your application code, install it on the connected device or emulator, and start the app.
    • If everything goes well, you should see your Flutter application running on the device or emulator.

Note: During the first run, Flutter may download additional packages and dependencies, which might take some time. Subsequent runs will be faster.

  1. Make changes to the default application:

    • Open your Flutter project in a text editor or an IDE (e.g., Visual Studio Code).
    • Navigate to the lib directory and open the main.dart file.
    • Modify the code to make changes to the default application.
    • Save the file.
  2. Hot reload and see the changes:

    • After making changes to your code, switch back to the Command Prompt or Terminal.
    • Press the r key and Enter to trigger a hot reload.
    • Flutter will recompile only the modified parts of your code and instantly reflect the changes in the running application.
    • You can repeat this step whenever you want to see the effects of your code changes without restarting the app.

Congratulations! You have successfully run your first Flutter application and learned how to make changes using hot reload. Now you can continue building and exploring Flutter by modifying your project code and exploring the Flutter framework's capabilities.

Tags : Flutter, Dart, Android, IOS
Share:

You May Also Like

Get 50% Discount.

Lorem, ipsum dolor sit amet consectetur adipisicing elit. Exercitationem, facere nesciunt doloremque nobis debitis sint?