Building a Flutter Ecosystem for Dart on Ubuntu with Visual Studio Code
How-to build a Flutter ecosystem for Dart to develop web applications on Ubuntu with Visual Studio Code
This is a sort of spin-off, because I don’t work with Dart yet, but I plan to do so in the near future. Being in quarantine since February, 26th (yes, I was born and I still live in Lombardy) I have lot of spare time to spend on learning new skills. Since I don’t work with “native” languages either, I built a web-based ecosystem: it’s still in beta and you shouldn’t use it in production. Flutter can deal with several platforms and I chose to get it working on Ubuntu 19.10 before trying it on WSL2 under Windows 10 too. Let’s get started with this.
First of, we need to resolve some dependencies. Ubuntu comes with most if not all of these packages pre-installed, so you don’t have to worry: Flutter also needs the latest version of Google Chrome. Chromium doesn’t seem to be supported. I assume that you already installed Visual Studio Code; I’ll show you later how-to get ready with this editor… just installing a simple extension. You may easily skip the step below if you run an official Ubuntu flavor, because it provides what you need by default and you already have it.
$ sudo apt-get update && sudo apt-get install bash coreutils curl debianutils git libglu1-mesa unzip xz-utils zip
While “native” builds are stable yet, the web-based component of Flutter is still in beta and you can’t download a compressed binary. Don’t worry, because its binaries are on GitHub and getting them is easy; you must switch to the correct branch if you don’t care about Android: you’ll see very soon what I mean. There are several ways to add the executable you’re downloading to your
$PATH, but I prefer a per-user configuration, even if I’ve only a registered account apart from root on my machine. Choose wisely.
$ git clone https://github.com/flutter/flutter.git -b beta
$ nano ~/.bashrc export PATH="$PATH:/path/to/flutter/bin"$ source ~/.bashrc
Now, you’re almost ready to go: if you need to develop “native” applications for both Android and iOS, then you should run
flutter precache to get all the required libraries. Here I just want to build for the web, so I skipped this step, but running
flutter doctor helps to identify missing dependencies and automatically downloads the Dart SDK. For my purposes, I got the official Visual Studio Code extension as underlined by the latest command we run. You don’t have to attach a physical device to your machine for doing this.
Next, I’ll show you how-to bootstrap a web application with Flutter to get it running on Google Chrome. I’m still playing with this framework! I guess that a strong Dart knowledge could help, as TypeScript does for Angular. Anyway, this is yet another option to build modern solutions on Ubuntu. I already have my favourite solution, but we’ll speak about it elsewhere. I think that, as a developer, is very important to stay up-to-date with all the available tools: different clients could use different platforms and I love to experiment.