Google and Canonical recently announced the availability of Flutter for Linux. The team behind Flutter is now working with Ubuntu developers to make Flutter for desktop a reality.
Apart from Android and iOS currently there is support for Linux and Mac. Windows is still under development.
So now if you want to give it a try and create a desktop application this is how to install and configure Flutter on Ubuntu.
Install Flutter
sudo snap install flutter --classic
According to the docs that command should also install the dependencies, but it wasn’t true in my case, so I had to install them manually:
sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev
Configure Flutter
In order to create desktop applications we have to run the following commands:
flutter channel dev flutter upgrade flutter config --enable-linux-desktop
Configure your IDE
If you are using IntelliJ:
- Go to Help->Find action… or hit Ctrl+Shit+A
- Search for «Plugins» and then install a plugin called Flutter
- Accept the installation of Dart that will popup and restart IntelliJ
Try it out!
Create a new Flutter project to see if everything works:
- Go to File->New->Project and select Flutter
- Select the location of the Flutter SDK, it should be something like:
/home/{your_user}/snap/flutter/common/flutter
- Give it a name and that’s it, you can now build and run the default application
And this is how the app looks when you run it on your Linux desktop. You can resize the window, click the increment button and and this is the best part: change the code and hot reload ❤️
Troubleshooting
If you want to test if everything is working at any point flutter doctor is a great tool that you can use. Just run the command or find «Flutter Doctor» from within IntelliJ or Visual Studio Code:
flutter doctor
Oh, don’t worry about errors like that, unless you are developing for Android of course!
Sources:
Thanks