Skip to content

Latest commit

 

History

History

readme.md

Convex Dart Example Project

This example project demonstrates how to use convex_dart with a real Convex backend, showcasing various types, patterns, and best practices.

Project Structure

example/
├── convex/                          # Convex backend (TypeScript)
├── lib/src/convex/                  # Generated Dart client code
│   ├── client.dart                  # Main ConvexClient class
│   ├── functions/                   # Generated function wrappers
│   ├── literals.dart                # Generated literal type classes
│   └── schema.dart                  # Generated schema types (e.g., TasksId)
├── package.json                     # Node.js dependencies for Convex
├── pubspec.yaml                     # Dart dependencies

How the Generation Works

  1. Convex Functions: TypeScript functions in convex/ define your backend API
  2. CLI Generation: convex_dart_cli generate reads your Convex functions and generates:
    • Type-safe Dart function wrappers
    • Serialization/deserialization logic
    • Schema types and literal classes
  3. Runtime Usage: Your Flutter app calls the generated functions, which handle:
    • Type conversion between Dart and Convex types
    • Network communication with your Convex backend
    • Real-time subscriptions and updates

Running the Example

  1. Install dependencies:

    npm install  # For Convex backend
    flutter pub get  # For Dart dependencies
  2. Generate Dart client:

    dart run convex_dart_cli generate --public-serialize
  3. Run the example:

    flutter run

Run the tests

  1. Install dependencies:

    npm install  # For Convex backend
    flutter pub get  # For Dart dependencies
  2. Generate Dart client:

    convex_dart_cli generate --public-serialize
  3. Run the tests: Build the shared library in convex_dart/rust.

    flutter test integration_test/test_all.dart