Flutter Commands Cheat Sheet



Getting Flutter and Android working together is no small feat.

Linux may be a first-class citizen when it comes to developing with Flutter, but setting up Java, Android and the Android tool-chain can be a real hassle.

This blog post shows how get Flutter working with Android SDK without installing Android Studio.

Step 4: Flutter provides a tool, flutter doctor to check that all the requirement of flutter development is met. Flutter doctor Step 5: Running the above command will analyze the system and show its report as shown below: Doctor summary (to see all details, run flutter doctor -v): √ Flutter (Channel stable, v., on Microsoft Windows Version. Flutter has a few builtin tools for helping you debug layouts. Flutter Inspector. In Android Studio you can find the Flutter Inspector tab on the far right. Here we see our layout as a widget tree. Visual rendering. You can turn on visual rendering by setting debugPaintSizeEnabled to true in your main function. In your main.dart file replace.

Android Studio is a fully-fledged IDE. If you want to use a different development editor (like Vim or VS Code), Android Studio is only good for eating space on your hard drive.

Arch Linux comes with the fabulous Arch package manager and the AUR, the Arch User Repository. The AUR offers dozens of useful packages which we can use to set up Android SDK.

Please be aware that you need around 7 GB of free disk space for Flutter and Android SDK.

Install Flutter⌗

Use the AUR for installing Flutter:

(yay enables you to install AUR packages.)

Choose Openjdk 8 or 10. Otherwise you’ll get an error with the Android tools:Failed to install android-sdk: “java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema”.

Fix Permissions⌗

Create a new group flutterusers, add the default user to the group, then change permissions on the folder /opt/flutter.

If you still get permission denied errors, you can also change the permissions of the /opt/flutter folder to your $USER:

Install Android SDK and Tools⌗

While we can avoid installing the heavy Android Studio program, we still need the SDK Manager.

You can install the SDK Manager command line tool as a standalone package. We also need the platform tools for the Android emulator and an SDK platform.

We need an Android platform, too. Either use the AUR:

Or use the sdkmanager (see below).

Add the following environment variables to your shell, see here:

Don’t forget to add this to your shell profile file (.bashrc or similar) to make the Android tools work across reboots.

In fish shell:

Fix User Permissions⌗

The AUR installs the Android tools into /opt/android-sdk. The directory has root permissions, so we’ll need to fix that:

You’ll probably also have to set up environment variables for ANDROID_SDK_ROOT and JAVA_HOME.

The Java version is under /usr/lib/jvm, in the case of version 10, it’s this:

Flutter Commands Cheat Sheet

Check find /usr/lib/jvm to see the exact path.

Don’t forget to add the environment variable to your bash profile file (.bashrc or similar).

For fish shell:

The variable ANDROID_SDK_ROOT should be set to /opt/android-sdk:

or

Android Emulator⌗

First, you’ll need to install the required Android image with sdkmanager:

Then install a system image, for example:

(If you didn’t install an Android platform via the AUR, use the sdkmanager to install a platform as well: sdkmanager --install 'platforms;android-29'.)

Now you can create an emulator:

(Replace <name> with the name you want to give the emulator.)

See avdmanager for more infos.

Here’s a handy cheat sheet on GitHub.

You might get errors that “there is no space lift on device”. The error indicates that your /tmp folder is full: I am getting a no space left on device error.

Try clearing the folder or increase the available space in /tmp (instructions in link above).

Add the emulator path to your user paths, for example, in Bash:

(Adjust to your needs.)

In my setup, I added the platform-tools and emulator:

It seems like sdkmanager adds some paths automatically. Make sure to check your installation to see what’s required.

For example, the error “PANIC: Missing emulator engine program for ‘x86’ CPUS.” indicates that the emulator program is not in your path.

In fish, you can check your path variables like this:

In Bash, there is no $fish_user_path but the second command should work, too.

Run Android Emulator⌗

Commands

Run Flutter⌗

First, let’s check if you have accepted all licenses: flutter doctor --android-licenses.

Then run flutter doctor -v.

Ideally, everything should work except Android Studio.

If not, make sure that you have all necessary tools on your machine and that you’ve set the environment variables.

Recap⌗

Installing the Android toolchain without Android Studio can be very tricky if you don’t add the correct paths to your shell environment.

It’s also not easy to find out what you have to install and how to do it.

The above worked for me after spending a few hours. Time I’ll never get back.
Hopefully, this guide will help someone else (and if it’s only my future self).

Further Reading⌗

In this post, I will list down some of the key commands (cheatsheet) which can help one build and release web application (app) using Flutter.

In order for the following commands to work, follow the steps given below:

  • Install Flutter: Make sure you have installed Flutter. Follow the steps in this page for setting up / installing flutter.
  • Create Flutter Project: Once installed, create a template project for getting started with a project. Use this page for creating a flutter project.

Flutter Commands for Web

Once flutter is set up and a template project is created, execute the following one-time commands for setting up Flutter web development environment. These commands can be run from anywhere in a terminal.

Once the above commands executed, go to the home / root folder of Flutter project and execute the following commands. The details of these commands can be found on this page titled as building web application using flutter.

Run the Flutter Project

Build the Web Project

Flutter Build Command

Create Release Build

Sheet

The command given below will populate build/web directory with built files, including an assets directory, which need to be served together. One should note that the minification is handled when one creates a release build.

The release build will create the following files / assets in build/web project folder. Take these files and put it in web root folder for any web server including Tomcat, Python, Firebase or cloud hosting (AWS, Google, Azure). More details can be found on this page related to deploying flutter app on web

Add Web Support to an Existing Project

Embed Flutter App in Web Page

Use the following command to embed flutter app in any webpage. URL is the link for flutter web page.

Flutter Commands Cheat Sheet Answers

  • First Principles Understanding based on Physics - April 13, 2021
  • Precision & Recall Explained using Covid-19 Example - April 11, 2021
  • Moving Average Method for Time-series forecasting - April 4, 2021