Flutter
Installation (Archlinux)
- Install flutter
yay -S flutter
- You then need to adjust the permissions of the binary and install folder so that we can run stuff as our user:
sudo groupadd flutterusers
sudo gpasswd -a $USER flutterusers
sudo chown -R :flutterusers /usr/lib/flutter
sudo chmod -R g+w /usr/lib/flutter
sudo chown -R :flutterusers /bin/flutter
sudo chmod -R g+w /bin/flutter
- Android -> Install the necessary packages:
yay -S android-sdk android-sdk-platform-tools android-sdk-build-tools
yay -S android-platform
- And also fix the permissions
sudo groupadd android-sdk
sudo gpasswd -a $USER android-sdk
sudo setfacl -R -m g:android-sdk:rwx /opt/android-sdk
sudo setfacl -d -m g:android-sdk:rwX /opt/android-sdk
- You’ll probably also have to set up environment variables for
ANDROID_SDK_ROOT
andJAVA_HOME
.
The Java version is under /usr/lib/jvm
, in the case of version 8, it’s this:
export JAVA_HOME='/usr/lib/jvm/java-8-openjdk'
Usage
Check installation
To check if flutter is correctly installed:
flutter doctor
Run the app locally
To run the app on linux:
flutter run
to use Hot Reload while running the app, you need to focus the terminal running the app and press r
.
Alternatively, use dashmon
To install it, run :
flutter pub global activate dashmon
and substitute flutter run
with dashmon
.
More information in the package page.
Projects
Project structure
Configuration
pubspec.yaml
is the configuration file for the app you are making.analysis_options.yaml
is the configuration file for code analysis.
main.dart
-
Every widget defines a build() method that's automatically called every time the widget's circumstances change so that the widget is always up to date.
-
Every build method must return a widget or (more typically) a nested tree of widgets. In this case, the top-level widget is Scaffold. You aren't going to work with Scaffold in this codelab, but it's a helpful widget and is found in the vast majority of real-world Flutter apps.
-
Having separate widgets for separate logical parts of your UI is an important way of managing complexity in Flutter.
-
safe area: takes into account expanded, takes the whole space