Flutter and Dart client
Add plexivo_client to your Flutter or Dart app and use Plexivo Postgres: queries, joins, Auth, Realtime over WebSockets and more.
plexivo_client is the Flutter and Dart client for Plexivo Postgres as a backend. It is pure Dart and null-safe, for Android, iOS, the web, macOS, Windows, Linux and servers, and needs Dart 3.4 or later. This page is for version 0.4.0.
The full reference, with every method and example, is on pub.dev.
Install#
flutter pub add plexivo_clientOr add it to pubspec.yaml:
dependencies:
plexivo_client: ^0.4.0Quick start#
create table todos (
id bigint generated always as identity primary key,
owner uuid not null default auth.uid(),
title text not null,
done boolean not null default false,
created_at timestamptz not null default now()
);
alter table todos enable row level security;
create policy own_todos on todos for all to authenticated
using (owner = auth.uid()) with check (owner = auth.uid());import 'package:plexivo_client/plexivo_client.dart';
final db = PlexivoClient(dataUrl, publishableKey);
await db.signUp(email: email, password: password);
await db.from('todos').create({'title': 'Ship it'});
final open = await db.from('todos').where('done', false).order('created_at', 'desc').limit(20);
print(open.first['title']);Pass the database’s Project URL and Publishable key, both on its Connect tab. In a Flutter app, pass them with --dart-define rather than writing them in your source.
Results#
Awaiting a query gives a PlexivoResult: a List<Map<String, dynamic>> that also carries count. first(id) and single() throw RecordNotFoundException when no row matches; firstOrNull and maybeSingle give null.
final page = await db.from('todos').select('id, title', 'exact').range(0, 9);
print('${page.length} of ${page.count}');
final maybe = await db.from('todos').firstOrNull(999999); // null
final one = await db.from('todos').where('title', 'Ship it').maybeSingle();
print(one.data?['title']);What it covers#
| Area | Methods | Guide |
|---|---|---|
| Queries | from, select, where and every operator, order, limit, range, paginate, count, aggregate, groupBy; Supabase’s eq, inFilter, isFilter, or, single | Queries |
| Joins | preload, joins, whereHas, withCount, orderReferenced, model relations | Joins |
| Writes | create, createMany, upsert, save, update, increment, delete | Writes |
| Transactions and functions | transaction with insert(…).ref(), lockForUpdate, rpc | Transactions |
| Auth | signUp, signInWithPassword, signInWithOtp, getOAuthSignInUrl, signInAnonymously, linkEmail, updateUser, authStateChanges, listSessions, mfa, orgs | Auth |
| Realtime | channel, changes, on, presence, statusChanges, ready | Realtime |
| GraphQL | graphql, graphqlSubscribe | GraphQL |
| Functions | functions.invoke | Functions |
| Server only | raw, exec, sql.transaction, migrate, migrator | Raw SQL |
A web build given the secret key throws secret_key_in_browser: the secret key belongs on servers only.
Keep sessions safe#
Store the session in encrypted device storage: save it from authStateChanges and pass it back as initialSession. The Flutter guide shows it with flutter_secure_storage.
Updated 28 October 2026