Flutter app
A Flutter app for iOS, Android and the web. lib/vaif_client.dart reads the project ID and publishable key from .env and creates the Dart client once, before main.dart starts the app.
Create the app
Section titled “Create the app”vaif init --template flutter-appRun it in a new, empty folder. It writes vaif.config.json and the template's files there. It stops if the folder already has a vaif.config.json, and leaves any other file that already exists alone; --force overwrites both.
It asks which features to include. This template has files for Database, Authentication and Functions; Database and Authentication are selected to start with. To skip the question, name them: vaif init --template flutter-app --features database,auth,functions. Add one later with vaif init --template flutter-app --add-features <feature>.
What it writes
Section titled “What it writes”| File | Written |
|---|---|
lib/main.dart | Always |
lib/vaif_client.dart | Always |
pubspec.yaml | Always |
.env.example | Always |
.gitignore | Always |
README.md | Always |
lib/models/database.dart | With Database |
lib/screens/login_screen.dart | With Authentication |
lib/services/functions_service.dart | With Functions |
Authentication adds a sign-in screen, Database adds model classes for your tables, and Functions adds a service that invokes your project’s functions.
Install
Section titled “Install”The code this template writes uses the client for its language:
pubspec.yaml lists the Dart client, so flutter pub get succeeds only once that client is published. Until then, call the REST API from Dart with an HTTP client.
Configure
Section titled “Configure”Copy .env.example to .env and fill it in. The project ID and the keys are on Security > Credentials in the console.
| Variable | Value |
|---|---|
VAIF_PROJECT_ID | Your project ID. |
VAIF_PUBLISHABLE_KEY | The project's publishable key (vk_pub_). Row rules apply to it, so it is safe in an app. |
Run it
Section titled “Run it”flutter pub getflutter run