Put your Flutter game on the web
Flutter track, Moderate and Advanced. Build a web copy of your Flutter game, package it with the editor, and host it on Netlify Drop or GitHub Pages.
Levels: Moderate, Advanced. Last checked: not yet on each host (due Oct 14–16).
Course buyers: this guide is also lesson 8.7 Install the Flutter app on their phone (Flutter only).
What you'll get: a web copy of your Flutter game that plays in any browser, packaged by the Pixelora editor and hosted on Netlify Drop (or, if you know GitHub, GitHub Pages). Handy when they have an iPhone and you don't want TestFlight.
Before you start: the Pixelora Flutter app runs on your own device (course lesson 7.4), and the Pixelora editor is installed in your game project.
Your photos go online with this. The web copy contains the photos the game uses, and anyone with its link can see them. Follow the privacy steps in the host guide you pick.
Moderatemore control
1. Build the web copy. In the Flutter app folder, copy the latest game in and build:
dart run tool/sync_project.dart [PROJECT FOLDER]
flutter build webA Flutter web build needs to know the path it's served from. flutter build web is right for Netlify
Drop, which serves the game at the root of its address. For GitHub Pages, which serves it at
/[repo]/, build with flutter build web --base-href /[repo]/ instead (the slashes matter). itch.io
serves games from a sub-folder you can't know in advance, so use Netlify Drop for a Flutter web copy.
2. Copy it into your game project. The editor only packages folders inside your game project, and
the Flutter app sits next to it. Copy the Flutter app's build/web folder into your game project
folder and name the copy flutter-web (Finder or File Explorer: copy, paste, rename).
3. Package it. In the Pixelora editor, Export → Folder with your built game: type
flutter-web, then Package my game. The zip lands in your project's export/ folder, with the
photos cleaned, like a web game's. If it warns that index.html has no noindex tag, add
<meta name="robots" content="noindex"> to the Flutter app's web/index.html, build and package
again before you host it.
4. Host it. Follow Netlify Drop (unzip and drop) or, for a build made
with --base-href /[repo]/, GitHub Pages.
Advanceddo it yourself
From the command line. From the game project folder (build with the right --base-href first):
rm -rf flutter-web && cp -R ../my-flutter-app/build/web flutter-web
npx pixelora export build --dir flutter-webThe packager only reads folders inside the project, so the copy step is needed when the Flutter app is a sibling folder (the default layout). Then unzip the result and deploy it with any static host, for example:
site=$(mktemp -d) && unzip -q export/[your-game]-build.zip -d "$site"
(cd "$site" && npx netlify-cli deploy --dir . --prod --no-build)Never deploy the Flutter app folder or the project folder itself, only the packaged build.
How to take it down
Use the take-down steps in the host guide you used: Netlify Drop or GitHub Pages.
Before you share
Do these four checks before you send the link to anyone:
- Open the link in a private window (or incognito). The start screen appears and the game plays. If you set a password, it asks for it first. (Installed an app instead? Open it once with the phone in airplane mode.)
- Test it on a phone, and if you can, on the kind of phone the person you made it for has.
- Make sure the game page isn't listed in search (web links only; an installed app isn't
online). A few days after publishing, search the web for your game's address: the game page
shouldn't show up. It asks search engines not to list it (a
noindextag), but check anyway. This covers only the game page: on GitHub Pages, the public repository behind it can still be found on GitHub (see that guide's warning). - Know how to take it down. Read the "How to take it down" steps above and find the button before you need it.
Only share the link with people you trust, and only with photos of people who are happy to be in the game. Anyone who has the link (and the password, if there is one) can see the photos in it.