Flutter Guide
Spooky provides Dart code generation for Flutter integration, allowing for natively typed data models.
Note
The Flutter/Dart client is currently in development. This guide shows the generated Dart models and how to use them with SurrealDB’s Dart client.
Generate Dart Models
Use the Spooky CLI to generate Dart models from your SurrealDB schema:
Bash
This generates Dart classes with JSON serialization for your schema tables.
Generated Models Example
The CLI generates strongly-typed Dart classes for each table in your schema:
lib/models.dart
dart
Usage with SurrealDB Dart Client
Use the generated models with the official SurrealDB Dart client:
lib/database.dart
dart
Flutter UI Example
Here’s how to use the database in a Flutter widget:
lib/screens/threads_screen.dart
dart
Next Steps
- Check out the SurrealDB Dart client documentation for more details
- Explore state management solutions like Riverpod for reactive data binding
- Consider implementing real-time updates using SurrealDB’s LIVE queries