* The cover image is originally by LMoonlight and edited with great appreciation.
Summary
Flutter 2 was released on March 3, 2021.
According to the official website:
Flutter is Google’s UI toolkit for building beautiful, natively compiled applications for mobile, web, and desktop from a single codebase.
I built its development environment in Arch Linux due to the official documentation:
Tutorial
Install dependencies
Pacman
Install Kotlin and Dart as programming language SDKs:
$ sudo pacman -Sy kotlin dart
$ # installing dart creates `/opt/dart-sdk`
$ # caution: use not dart-sdk-dev in AUR but dart
Then, JDK version may be asked. It's OK to choose the default:
:: Synchronizing package databases...
system 225.2 KiB 172 KiB/s 00:01 [#################################] 100%
world 1615.2 KiB 1237 KiB/s 00:01 [#################################] 100%
galaxy 1535.9 KiB 4.41 MiB/s 00:00 [#################################] 100%
extra 1620.3 KiB 453 KiB/s 00:04 [#################################] 100%
community 5.5 MiB 786 KiB/s 00:07 [#################################] 100%
resolving dependencies...
:: There are 6 providers available for java-environment>=8:
:: Repository world
1) jdk-openjdk 2) jdk11-openjdk 3) jdk8-openjdk
:: Repository extra
4) jdk-openjdk 5) jdk11-openjdk 6) jdk8-openjdk
Enter a number (default=1):
looking for conflicting packages...
Packages (4) java-environment-common-3-3 jdk-openjdk-15.0.2.u7-1 dart-2.12.2-1 kotlin-1.4.32-1
Total Download Size: 237.99 MiB
Total Installed Size: 618.73 MiB
:: Proceed with installation? [Y/n] y
Optionally, install adb
, Android Debug Bridge, etc. provided by android-tools:
$ sudo pacman -Sy android-tools
For your reference, Arch Linux has a wiki page about Android.
AUR
Install AUR, Arch User Repository, packages:
$ # flutter
$ git clone https://aur.archlinux.org/flutter.git
$ cd flutter
$ makepkg -si
$ cd ..
$ # android-sdk
$ # installed in Android Studio first configuration later
$ # android-studio
$ git clone https://aur.archlinux.org/android-studio.git
$ cd android-studio
$ makepkg -si
$ cd ..
Add permission on /opt/flutter
which is created in installing flutter
:
$ sudo gpasswd -a <your-user> flutterusers
Log out and log in again.
Launch Android Studio. The first configuration will start.
Choose your option on sending analytical data and so on, and click "Next" several times:
And the installation of Android SDK and its platform tools will begin.
It will take time. When the process is finished, quit Android Studio.
Run flutter doctor
with --android-licenses
option to install Android licenses. You will be asked if you accept them:
$ flutter doctor --android-licenses
$ # choose "y", "y", ...
After accepting all of them, run flutter doctor
without any options, which will be successful:
$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.6, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Chrome - develop for the web
[✓] Android Studio
[✓] Connected device (1 available)
• No issues found!
Prepare Android Studio
Launch Android Studio again. Select "Plugins" menu:
Install "Flutter" plugin. Here, "Dart" is automatically selected and you will be confirmed to install it together:
Flutter is installed with Dart.
Click "Restart IDE" button to restart Android Studio.
Create a project
In Android Studio start menus, you will see "Create New Flutter Project":
Choose "Flutter Application":
"Flutter SDK path" is /opt/flutter
:
Almost done.
Run a demo app
You will see the project structure.
lib/main.dart
is the primary file.
Select device, and the emulator will start.
Click the "Run 'main.dart' (Shift+F10)" Button in the menu bar above, which is a green triangle to the right of "Loading Devices...".
Here is you Flutter 2 app in your hand😃
Besides, you can also create another project.
Discussion (0)