Running Flutter Desktop on MacOS

Flutter Desktop used to be a separate experimental project, and it was moved to the flutter GitHub repository recently as it has gotten more mature.

The doc says that it is easiest to run a Flutter desktop app on MacOS, but that it still requires some tinkering if you want to compile and run natively on Windows and Linux.

The official doc (see screenshot below. link here) actually describes the whole process, and yet, since I wasn't reading very carefully, I missed some important information. So take a look at this, then scroll down to see the commands I actually had to run.

The point I had missed was "you must be on the master branch". I was on the beta branch, and so I assumed that I would automatically get the feature. I was wrong!

 % flutter config --enable-macos-desktop
Setting "enable-macos-desktop" value to "true".

You may need to restart any open editors for them to read new settings.

% flutter config

  enable-web: true
  enable-macos-desktop: true (Unavailable)

It's only after I switched to the master branch that macos-desktop was made available.

% flutter channel master

Switching to flutter channel 'master'...
git: Switched to a new branch 'master'
git: Branch 'master' set up to track remote branch 'master' from 'origin'.

% flutter config
Downloading Dart SDK from Flutter engine eb139936eb2c17694aba3fd922adfe8a85c5e8df...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  193M  100  193M    0     0  37.4M      0  0:00:05  0:00:05 --:--:-- 40.6M
Building flutter tool...
Configure Flutter settings.

  enable-web: true
  enable-macos-desktop: true

Then I created an app with flutter create app, and ran it:

% flutter run      
More than one device connected; please specify a device with the '-d <deviceId>' flag, or use '-d all' to act on all devices.

macOS      • macOS      • darwin-x64     • Mac OS X 10.15.2 19C57
Chrome     • chrome     • web-javascript • Google Chrome 79.0.3945.88
Web Server • web-server • web-javascript • Flutter Tools

% flutter run -d macOS
Running "flutter pub get" in app...                                 0.4s
Launching lib/main.dart on macOS in debug mode...