Skip to content

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.

Terminal window
vaif init --template flutter-app

Run 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>.

FileWritten
lib/main.dartAlways
lib/vaif_client.dartAlways
pubspec.yamlAlways
.env.exampleAlways
.gitignoreAlways
README.mdAlways
lib/models/database.dartWith Database
lib/screens/login_screen.dartWith Authentication
lib/services/functions_service.dartWith 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.

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.

Copy .env.example to .env and fill it in. The project ID and the keys are on Security > Credentials in the console.

VariableValue
VAIF_PROJECT_IDYour project ID.
VAIF_PUBLISHABLE_KEYThe project's publishable key (vk_pub_). Row rules apply to it, so it is safe in an app.
Terminal window
flutter pub get
flutter run
  • Dart SDK for the client’s state and what it will cover.
  • REST API for every route.