After installing the Flutter and Android SDK several times on different machines I always ended up with a broken setup where some part of the puzzle was not working anymore.
I decided to improve this situation but wanted no limitations compared to a local installation. So the image must be able to execute Flutter in my current host directory, start an emulator and hot reload the app and let me test Flutter for Web.
This is what I've come up with:
and support the following features:
- Use Flutter commandline tool
- Start an emulator and hot reload the app on it (with hardware accerlation)
- Serve Flutter app as Web app
On my machines I setup some aliases to transparently map a
docker run command. Executing Flutter in the image feels just as executing it locally.
For me the best feature is a predictable behavior on all my machines with no traces. With two commands you will have the flutter example app up and running.
docker run --rm -e UID=$(id -u) -e GID=$(id -g) --workdir /project -v "$PWD":/project matspfeiffer/flutter create . xhost local:$USER && docker run --rm -ti -e UID=$(id -u) -e GID=$(id -g) -p 42000:42000 --workdir /project --device /dev/kvm --device /dev/dri:/dev/dri -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY -v "$PWD":/project --entrypoint flutter-android-emulator matspfeiffer/flutter
I agree - the commands are not looking very friendly - but mapped with an alias it's just like:
flutter create . flutter-start-emulator
I am using Linux as my operating system which could mean that there are bugs for MacOS and Windows. Especially forwarding the X system and qemu accerlation could be an interesting task under Windows and MacOS. I already read that it is possible but I could need help with testing it. A
If your are interested feel free to test the image and issue bugs. I would really appreciate any support to make this image usable for everyone who want's to start with Flutter.
So hopefully we hear again in the comments or at Github!
Checkout the README to read about solutions for Windows and MacOS users as well!