Build a Flutter app on your machine

An app from Oalo's Flutter template on your machine, against your Base's sync and sign-in: get its code, generate its Dart models, run it, deploy.

An app made from Oalo's Flutter template already signs people in with an email code and keeps its data in sync with your Base, offline included. You can build it on your own machine with your own editor and agent, against your Base, and deploy from there.

1. Get the code

Make the app in the dashboard (a new app, Flutter). Then, in an empty folder:

git init
oalo login
oalo deploy --app <slug> --pull   # oalo apps lists them
git merge oalo/<slug>
oalo link --app <slug>

The code arrives as the Base has it, with its address already in lib/config.dart. Link after the merge, not before: oalo link writes a .gitignore, and git refuses to merge the app's own .gitignore over an untracked one.

2. Packages

flutter pub get

You need a Flutter whose Dart is 3.9.2 or newer, because synclib_sync requires it. The current stable channel is fine; flutter --version shows both.

The template lists synclib_flutter and synclib_sync by their public https address, but synclib_sync itself pulls synclib_flutter by its git@github.com: address, so git needs an SSH key on your GitHub account. Without one, tell git to use https for them, once (the Base does the same):

git config --global url."https://github.com/synclib-io/".insteadOf "git@github.com:synclib-io/"

3. Models

oalo typegen --dart

It writes lib/sync/generated/ and lib/models/ with the same generator the Base uses, so they match what the dashboard and the Base's own agent see. Run it again after you add or change a model (oalo data models create, or in Data). --check fails when they're out of date, for CI. Commit them.

It also writes .oalo/dart-defines.json: your Base's address, the app's slug and the env (dev).

4. Run it

flutter run -d chrome --dart-define-from-file=.oalo/dart-defines.json

The same file works for -d ios and -d android. The app reads and writes your Base's dev data, the same as its preview. Sign in with a real email address: the code is sent to it.

  • Shared data (a model marked shared: a catalog, articles, posts) syncs to everyone, signed in or not, and changes show up live.
  • A member's own data syncs only to that member, once signed in. A screen that writes must sit behind RequireAuth.

5. Deploy

Commit, then oalo deploy updates the preview, and oalo deploy --env prod builds and publishes the live app. The live web app reads prod data.

Common mistakes

  • Running without the defines file. The web app then talks to flutter run's own address and never connects. Pass --dart-define-from-file=.oalo/dart-defines.json.
  • Old models after a model change. Run oalo typegen --dart again.
  • No app slug in the defines file. oalo link --app <slug>, then oalo typegen --dart again.
Related
Try it on your own Base

Sign up, install the CLI, and deploy your repo in a few minutes.

bring your repo