This example project demonstrates how to use convex_dart with a real Convex backend, showcasing various types, patterns, and best practices.
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
- Convex Functions: TypeScript functions in
convex/define your backend API - CLI Generation:
convex_dart_cli generatereads your Convex functions and generates:- Type-safe Dart function wrappers
- Serialization/deserialization logic
- Schema types and literal classes
- 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
-
Install dependencies:
npm install # For Convex backend flutter pub get # For Dart dependencies
-
Generate Dart client:
dart run convex_dart_cli generate --public-serialize
-
Run the example:
flutter run
-
Install dependencies:
npm install # For Convex backend flutter pub get # For Dart dependencies
-
Generate Dart client:
convex_dart_cli generate --public-serialize
-
Run the tests: Build the shared library in
convex_dart/rust.flutter test integration_test/test_all.dart