Flutter is a new way to rapidly build high-quality apps for iOS and Android. If you’re new to mobile development, or looking for a faster way to build apps, I recommend checking it out.
The install guide has all the details, but this post covers the basics of what you need to do on a Mac. It assumes some basic Mac knowledge and comfort with the command line.
Get the Flutter SDK
- You'll need to clone the Flutter SDK from GitHub first. Open a new terminal window and type "git clone -b beta https://github.com/flutter/flutter.git". This will download the SDK files.
- Next, add the Flutter tools to your system path by typing "export PATH=$PWD/flutter/bin:$PATH". Now when you type "flutter" commands, your system will know where to find them.
- Run "flutter doctor" to install any other dependencies. This may take a few minutes.
Once that's done, you have the Flutter SDK! Now you need the Android SDK to run apps. You can use Android Studio or Xcode - let's go with Android Studio.
Get the Android SDK
- Download and install Android Studio from their website. Launch it to let it download the Android SDK for you. Once that's done, you can close Android Studio.
- Back in the terminal, run "flutter doctor" again to check that the Android tools were found. If you see "[✓] Android toolchain", you're good to go!
Now let's create a demo app. Type "flutter create my_first_app" to generate the project files.
Create an Android Emulator
Your first demo app will run inside an emulator.
- Open Android Studio
- Choose “open existing project”
- Select the my_first_app directory, which flutter create created for you
- Using the Android Studio menus, select Tools > Android > AVD Manager
Click “Create Virtual Device”
- Choose Pixel 2, click Next
- Click Download for Oreo and accept the license
- Wait for the images and SDKs to finish downloading
- Choose Oreo for the system image, and click Next
- Accept the defaults, click Finish
Now that you have an emulator (also known as a Virtual Device), you need to launch it.
- Click the green arrow under “Actions” in the “Your Virtual Devices” window.
- Wait for the emulator to boot up
- Once you see the Android desktop in the virtual device, go back to the Terminal, ensure you are in the my_first_app directory, and type flutter devices.
- Go to Terminal, and type
flutter doctor --android-licenses
Accept the Android SDK licenses
Run your demo app
With the emulator running a virtual Android device, you can now run your app!
- In the Terminal, ensure you are in my_first_app directory, and type flutter run
- (Allow incoming network connections to the java process, if you see that popup)
- Wait for initial dependencies to download and configure
And there you have it - your first Flutter app running! Let me know if any part of the process needs more explanation.
FAQ:
People also Ask for:
Q:How to install flutter on windows?
0 Comments