How to create new project in flutter
To create a new Flutter project, you can follow these steps:
Method 1: Using the Flutter CLI
- Open a terminal or command prompt.
- Install Flutter by running the following command:
flutter --version
(if you haven't already). - Create a new directory for your project and navigate to it:
mkdir my_app
andcd my_app
. - Run the following command to create a new Flutter project:
flutter create my_app
. - Follow the prompts to choose the project template and settings.
- Once the project is created, navigate to the project directory:
cd my_app
. - Run the project using the following command:
flutter run
.
Method 2: Using Android Studio
- Open Android Studio.
- Click on "Start a new Flutter project" in the welcome screen.
- Choose the project template and settings:
- Project name: Enter a name for your project (e.g., "my_app").
- Project location: Choose a location to save your project.
- Package name: Enter a package name for your project (e.g., "com.example.my_app").
- Language: Choose the language you want to use (e.g., Dart).
- Click "Next" and then "Finish" to create the project.
- Once the project is created, you can run it by clicking the "Run" button or by using the command
flutter run
in the terminal.
Method 3: Using Visual Studio Code
- Open Visual Studio Code.
- Install the Flutter extension by searching for "Flutter" in the Extensions panel.
- Create a new folder for your project and navigate to it.
- Open the terminal in VS Code by clicking on "Terminal" > "New Terminal" or by using the keyboard shortcut
Ctrl + Shift +
(backtick). - Run the following command to create a new Flutter project:
flutter create my_app
. - Follow the prompts to choose the project template and settings.
- Once the project is created, navigate to the project directory:
cd my_app
. - Run the project using the following command:
flutter run
.
Regardless of the method you choose, you will now have a new Flutter project set up with a basic directory structure and a main.dart
file. You can start building your app by modifying this file and adding new files and directories as needed.