Running an Android app in Flutter requires Android SDK and an emulator or a connected Android device and running an iOS App requires Xcode and a simulator or a connected iOS device
Use following command to check if required dependencies are installed
flutter doctor
This command checks environment and displays a report to the terminal window
If flutter is not installed check Installing Flutter
Flutter requires Android Sdk
Check Installation in Linux
Use Java 8 instead of Java 14, which might lead to gradle issues
Install java 8 (if not already) with
sudo apt-get install openjdk-8-jdk openjdk-8-jre
Check there's other version(s) of java installed
update-java-alternatives -l
Switch to java 8 using its path (or name)
sudo update-java-alternatives -s /usr/lib/jvm/java-1.8.0-openjdk-amd64
Check version
java -version
If not created already, create app using flutter command
flutter create nc_app
where nc_app is name of the application
By convention, Flutter apps and packages are named in lower case and words are separated by underscore (_
)
Change current working directory (here nc_app)
cd nc_app
Skip this step to set up an emulator instead
An Android device running Android 4.1 (API level 16) or higher is required to run Flutter application
Enable Developer options and USB debugging on your device (check Android documentation)
Connect phone to computer using a USB cable
If prompted on device, authorize computer to access device
In the terminal, run the flutter devices
command to verify that Flutter recognizes your connected Android device
This step can be skipped if a real device is connected
Emulator can be started using emulator
command or using Android Studio
For systems with low memory, use emulator command to avoid waiting for applications to open up or (probably) freezing the system
To use emulator command, a device has to be created first using Android Studio → Avd Manager
Open Avd Manager using Configuration dropdown when Android Studio is started or
Android Studio → Tools → AVD Manager
or Android Studio → Tools → Android → AVD Manager
Create Virtual Device
Select Pixel 2 and press Next
Download an image shown under Recommended Tab
Select an Image
Click Next and Select Advanced Settings
Select Hardware Gles
Click Finish and then start the device
Open Terminal and enter
emulator -list-avds
If it doesn't show a device, create a Virtual Device by following above steps
Start emulator using emulator -avd <Device Name>
command
emulator -avd Pixel_2_API_28
Use following command to run a Flutter application
flutter run
Open lib/main.dart in a text editor and edit some lines
Press r on terminal to Hot reload
Press Shift + r for hot restart
Re run flutter run
command when editing pubspec.yaml
or adding, removing files used in application, in case
Check Flutter run issues
To prepare to run and test Flutter app on iOS simulator, follow these steps:
On Mac, find Simulator via Spotlight or by using the following command:
open -a Simulator
Start a simulator of a 64-bit device (iPhone 5s or later) by navigating to Hardware → Device menu
To check connected devices, run
flutter devices
If not created already, create app using flutter command
flutter create nc_app
where nc_app is name of the application
By convention, Flutter apps and packages are named in lower case and words are separated by underscore (_
)
Change current working directory (here nc_app)
cd nc_app
Use flutter run command to run flutter application
flutter run
This command internally runs flutter pub get
and pod install
to install required dependencies and runs the application on a connected device
Open Xcode
Navigate to File → Open
Navigate to and select (flutter project directory) → ios → Runner.xcodeproj and click Open