Setting up the Flutter Dev Environment

1 Set up Dev Evironment

DO NOT INSTALL VIM'S YCM WITH ANACONDA'S PYTHON, USE THE ONE FROM I.E sudo apt install python3-dev

1.1 Downloading the binaries

1.1.1 Android DevTools

Head to the Android devtools download page and go to the bottom-most section "Command line tools only". Download the appropiate zip file and unzip it to the ~/bin/android-home/cmdline-tools folder, or any other root folder you want but be warned that onwards I will assume that the user binaries are held inside the ~/bin/** directory. Make sure that the directory structure follows the guidelines described in this Stack Overflow answer otherwise you won't be able to fetch the sdk devices repo.

# the 'android-home' folder scaffold should look like this:
$ ls android-home
  build-tools
  cmdline-tools
    tools
  emulator
  licenses
  patcher
  platform-tools
  platforms

1.1.2 Flutter

$ cd ~/bin
$ git clone https://github.com/flutter/flutter.git -b stable --depth 1

1.2 Setting up the tools

Add the following lines yo your .zshrc or .bashrc file.

export ANDROID_HOME="$HOME/bin/android-home"
export PATH="$PATH:~/bin/flutter/bin"
export PATH="$PATH:$ANDROID_HOME/tools/bin"

Then you can proceed to execute the following commands to prevent Google from phoning home.

$ flutter
$ flutter config --no-analytics
$ dart --disable-analytics

Install the sdk tools as described in the official documentation for sdkmanager and accept all licenses otherwise the subsequent commands won't work.

# select the platforms to install with sdkmanager --list | less
sdkmanager "platform-tools" "build-tools;29.0.3" "platforms;android-29" "system-images;android-29;google_apis;x86_64"
sdkmanager --licenses
avdmanager create avd -n android-29 -k  "system-images;android-29;google_apis;x86_64"
# run the emulator as a background process (pipe output to the void and disown the process)
$ANDROID_HOME/tools/emulator -avd android-29 -gpu host $>/dev/null &!

We need to fetch the dart sdk

cd ~/Downloads
cd wget https://storage.googleapis.com/dart-archive/channels/stable/release/latest/sdk/dartsdk-linux-x64-release.zip
unzip dartsdk-linux-x64-release.zip -d ~/bin

1.2.1 Vim config

Install VIM from source following these instructions.

Enabling python3 support

$ sudo apt install python3.8 python3.8-dev python3.8-venv
$ make distclean
$ ./configure --enable-python3interp=yes --with-python3-command=/usr/bin/python3.8 --with-python3-config-dir=/usr/lib/python3.8/config-3.8-x86_64-linux-gnu --prefix=/usr
$ sudo make clean install

We are stealing some lines from the YouCompleteMe lsp examples and adapting the lines with the information provided here.

# Make sure to have these installed
# Plug 'dart-lang/dart-vim-plugin'
# Plug 'thosakwe/vim-flutter'

let g:ycm_language_server = [
\    {
\       'name': 'dart',
\       'cmdline': [ 'dart', '~/src/dart-sdk/dart/analysis_server.dart.snapshot', '--lsp' ],
\       'filetypes': [ 'dart' ]
\    }]

Author: Leandro Bravo

Created: 2020-09-01 Tue 20:20

Validate