Skip to main content
The official Dart SDK for TrailBase provides a fully-typed client for accessing your TrailBase backend from Flutter and Dart applications.

Installation

Add trailbase to your pubspec.yaml:
pubspec.yaml
Then run:
Or for Flutter:

Initialization

Basic Client

Client with Tokens

Restore a previous session with saved tokens:

Auth State Listener

Authentication

Login

Login with OAuth (PKCE)

Logout

Current User

Access Tokens

Refresh Token

Record API

List Records

Read a Record

Create a Record

Create Multiple Records

Update a Record

Delete a Record

Filtering

Available Comparison Operators

Real-time Subscriptions

Subscribe to a Single Record

Subscribe to All Records

File Handling

Image URIs

Record ID Types

TrailBase supports both integer and UUID record IDs:

Error Handling

Flutter Integration Example

Type Definitions

User

Tokens

ListResponse

Pagination

Best Practices

Use the onAuthChange callback to persist tokens and update your app’s authentication state.
Store tokens securely using packages like flutter_secure_storage instead of shared preferences.
The client automatically refreshes auth tokens before they expire.