How to Install Flutter and Dart on Any GNU/Linux Distro
Flutter is a Framework/ToolKit and Dart is a scripting language, both from Google.
What is Flutter?
Flutter (codenamed “Sky” during development) is an open source user interface development kit (UI toolkit and framework), created by Google in 2015, based on the Dart programming language, which enables creating natively compiled apps for Android, iOS, Windows, Mac, Linux, and Fuchsia and Web operating systems.
The main components of Flutter include:
- Dart programming language
- Flutter Engine
- Foundation Library
- Design-specific Widgets with ready implementations for Android (Google Material) and iOS (Cupertino)
The main advantages of the toolkit/framework:
- High productivity, coming from a cross-platform, you can use the same codebase for your iOS and Android app. …
- High performance;
- Fast development;
- Simplicity;
- Compatibility.
Flutter apps are written in the Dart programming language and make use of many of the language’s more advanced features.
What is Dart?
Dart (originally named Dash) is a web-based scripting language developed by Google. The goal of the Dart language was initially to replace JavaScript as the main language built into browsers. Programs in this language can either run in a virtual machine or be compiled to JavaScript.
In November 2013, the first stable version, Dart 1.0, was released In August 2018, Dart 2.0 was released, a reboot of the language, optimized for client-side development for web and mobile devices.
Installation
Dart SDK ships with Flutter; it is not necessary to install Dart separately. The Flutter SDK includes the complete Dart SDK and has the
dart
command.
01. Download the package that has everything (flutter
and dart
):
Check here for a newer version!
wget https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.3.10-stable.tar.xz
02. Extract the package:
tar xf flutter_linux_3.3.10-stable.tar.xz
03. Move to optional directory:
sudo mv flutter/ /opt/
04. Export Flutter’s bin/
to your $PATH
:
echo 'export PATH="${PATH}:/opt/flutter/bin"' | sudo tee -a /etc/profile
source /etc/profile
05. Test the commands: flutter
and dart
:
flutter --version
dart --version
Creating a Hello, World! in Dart
Create a file with the name you want and extension: .dart
, example: vim main.dart
and insert the content below:
void main(){
print("Hello, World!");
}
To run the code:
dart main.dart
To compile and run the binary:
dart compile exe main.dart -o hello
./hello
Creating a Hello, World! with Flutter
flutter create my_app
cd my_app
flutter run
There are several ways to display, read the outputs, however the simplest is using Google Chrome. If flutter run
doesn’t list this option, do it like this:
Example Google Chrome binary path in Gentoo.
CHROME_EXECUTABLE=/usr/bin/google-chrome-stable
export CHROME_EXECUTABLE
For convenience, add this to your /etc/profile
echo 'CHROME_EXECUTABLE=/usr/bin/google-chrome-stable' | sudo tee -a /etc/profile
echo 'export CHROME_EXECUTABLE' | sudo tee -a /etc/profile
source /etc/profile
When you run the
flutter doctor
command, it describes this!
It’s an app that you click on the +
button and it adds/adds to the count:
The file to edit is: vim ./my_app/lib/main.dart
If you choose option 1 (you need to have clang
and gtk
installed), it will open in a new window, as in the example below:
Alternatively you can use snapd to install:
sudo snap install flutter --classic
Although native to Ubuntu, it is available for several distros!
For example in Gentoo:
emerge snapd
.
- https://docs.flutter.dev/get-started/install/linux
- https://dart.dev/get-dart
- https://en.wikipedia.org/wiki/Flutter
- https://en.wikipedia.org/wiki/Dart_(programming_language)
flutter dart programming gnu linux
Comments