instantdb_flutter 0.2.5 copy "instantdb_flutter: ^0.2.5" to clipboard
instantdb_flutter: ^0.2.5 copied to clipboard

A real-time, offline-first database client for Flutter with reactive bindings.

0.2.5 #

๐ŸŽฏ API Enhancement: Documents Getter for Better Developer Experience #

Added Convenience API

  • โœ… Added documents getter to QueryResult - Provides direct access to query results using familiar API pattern
  • โœ… Enhanced developer experience - Developers can now use result.documents.length as expected
  • โœ… Backward compatibility - Existing result.data?['collection'] API continues to work unchanged
  • โœ… Smart collection detection - Automatically returns documents from the first collection in query result

Technical Implementation

  • โœ… First collection fallback - Returns documents from the first collection when multiple collections exist
  • โœ… Safe empty list handling - Returns empty list for loading, error, or null data states
  • โœ… Type safety - Ensures all returned items are properly typed as Map<String, dynamic>

๐Ÿ“š Impact #

This release solves an API discrepancy where developers expected a documents field on QueryResult but had to use the more verbose result.data?['collection'] pattern. Now both approaches work:

New convenient API:

final result = db.query({'conversations': {}}).value;
print('Returned ${result.documents.length} documents');

Existing API (still works):

final conversations = result.data?['conversations'] as List? ?? [];
print('Returned ${conversations.length} conversations');

0.2.4 #

๐ŸŽฏ Critical Fix: Entity Type Resolution in Datalog Conversion #

Fixed Entity Type Mismatch Bug

  • โœ… Fixed entities being cached under wrong collection name - Queries for 'conversations' no longer return 0 documents when entities lack __type field
  • โœ… Proper entity type detection - Extract query entity type from response data['q'] field and use it throughout conversion pipeline
  • โœ… Correct cache key resolution - Entities are now cached under their query type instead of defaulting to 'todos'

Technical Solution

  • โœ… Query type extraction - Parse the original query from response to determine intended entity type
  • โœ… Type propagation - Pass entity type through entire datalog conversion pipeline
  • โœ… Smart grouping - Use query type when grouping entities, fallback to __type field, then 'todos'
  • โœ… Cache alignment - Ensure cached collection names match query collection names

๐Ÿ“š Impact #

This release completes the datalog conversion fix trilogy. The critical bug was:

  1. App queries for {'conversations': {}}
  2. Server returns datalog with conversation entities
  3. Entities lack __type field, so they default to 'todos'
  4. Cache stores them under 'todos' key
  5. Query engine looks for 'conversations' and finds nothing

Now fixed: Entities are cached under the correct collection name matching the original query.


0.2.3 #

๐Ÿ”ฅ Critical Fix: Race Condition in Query Execution #

Fixed Critical Race Condition

  • โœ… Fixed queries returning 0 documents despite successful datalog conversion - Eliminated race condition where queries returned empty results before cache was populated
  • โœ… Synchronous cache checking - Queries now check cache synchronously before returning Signal, ensuring immediate data availability
  • โœ… Added "Reconstructed X entities" logging - Clear logging confirms entities are successfully parsed from join-rows

Technical Improvements

  • โœ… Synchronous initialization - Query Signals are now initialized with cached data if available, preventing empty initial results
  • โœ… Enhanced logging pipeline - Added comprehensive logging throughout datalog conversion: parsing, reconstruction, grouping, and caching
  • โœ… Immediate data availability - Applications receive data immediately when cache is populated, no async delays

๐Ÿ“š Impact #

This release fixes the final piece of the datalog conversion issue. While v0.2.2 added caching, there was still a race condition causing queries to return empty results. Now:

  1. Cache is checked synchronously BEFORE creating the query Signal
  2. Query results are initialized with cached data immediately
  3. Applications receive data without any race conditions
  4. Full visibility into datalog processing with enhanced logging

The complete fix ensures: No more "0 documents" when data exists. The package now properly converts datalog, caches it, AND returns it immediately to applications.


0.2.2 #

๐Ÿš€ Major Fix: Query Result Caching for Datalog Format #

Fixed Critical Issue

  • โœ… Fixed datalog format not being returned as collection format - Applications now receive properly converted collection data instead of raw datalog format
  • โœ… Added query result caching - Converted datalog results are cached for immediate access, solving the "0 documents" issue
  • โœ… Improved data availability - Queries now return cached results immediately after datalog conversion, without waiting for async storage operations

Technical Improvements

  • โœ… Query result cache in SyncEngine - Stores converted collection data from datalog processing
  • โœ… Cache-first query strategy - QueryEngine checks cache before querying storage
  • โœ… Smart cache invalidation - Cache clears when local transactions affect collections
  • โœ… Enhanced query filtering - Apply where, orderBy, limit, and offset to cached data

Architecture Enhancements

  • โœ… Direct data path - Datalog conversion results are immediately available to queries
  • โœ… Reduced latency - No dependency on async storage operations for query results
  • โœ… Better synchronization - Ensures data consistency between datalog processing and query results

๐Ÿ“š Impact #

This release fixes a critical issue where applications using the InstantDB Flutter package would receive 0 documents from queries, even though the package successfully processed datalog internally. The fix ensures that:

  1. Datalog format is properly converted to collection format
  2. Converted data is immediately available to applications
  3. No data loss occurs during the conversion process
  4. Applications no longer need workarounds to parse datalog manually

For AppShell Users: While AppShell v0.7.19+ includes a workaround, updating to InstantDB Flutter v0.2.2 provides the proper fix at the package level.


0.2.1 #

๐Ÿ› Critical Bug Fixes #

Enhanced Datalog Processing

  • โœ… Fixed datalog-result format edge cases - Resolved scenarios where malformed join-rows or unexpected data structures could cause silent failures, leading to empty query results despite data existing in the response
  • โœ… Added robust format detection - Implemented comprehensive datalog format detection that handles multiple variations including nested structures and different datalog path locations
  • โœ… Enhanced error logging - Added detailed logging for unrecognized query response formats to aid debugging instead of failing silently
  • โœ… Multiple fallback paths - Added systematic fallback logic that tries various datalog extraction methods before falling back to simple collection format
  • โœ… Improved delete detection - Better handling of entity deletions across different data formats and connection states

Connection & Timing Improvements

  • โœ… Fixed connection timing race conditions - Resolved timing-dependent format detection failures during connection initialization that could cause datalog responses to be ignored
  • โœ… Enhanced message type handling - Improved processing of different query response message types (add-query-ok, refresh-ok, query-invalidation) with varying data structure expectations
  • โœ… Added explicit failure warnings - Replaced silent failures with explicit warnings when query responses don't match expected formats

๐Ÿ”ง Technical Improvements #

Code Quality

  • โœ… Modularized datalog processing - Refactored datalog handling into focused, testable methods for better maintainability
  • โœ… Enhanced type safety - Improved type checking and reduced unnecessary casts in datalog processing logic
  • โœ… Better error reporting - Added comprehensive logging at different levels to help debug datalog processing issues

Architecture

  • โœ… Robust conversion pipeline - Implemented a systematic approach to converting datalog-result format to collection format with multiple validation points
  • โœ… Improved data flow - Enhanced the data processing pipeline to handle edge cases gracefully while maintaining performance

๐Ÿ“š Documentation #

  • โœ… Updated CLAUDE.md with detailed information about datalog processing improvements
  • โœ… Added documentation for debugging datalog format detection issues

0.2.0 #

๐Ÿš€ Major Features - React/JS SDK Feature Parity #

New Transaction System (tx namespace)

  • โœ… Added fluent tx namespace API for cleaner transactions (db.tx['entity'][id].update({}))
  • โœ… Implemented transactChunk() method for transaction chunks
  • โœ… Added merge() operation for deep nested object updates
  • โœ… Added link() and unlink() operations for entity relationships
  • โœ… Implemented lookup() references to reference entities by attributes instead of IDs

Advanced Query Operators

  • โœ… Added comparison operators: $gt, $gte, $lt, $lte, $ne
  • โœ… Added string pattern matching: $like, $ilike with wildcard support
  • โœ… Added array operations: $contains, $size, $in, $nin
  • โœ… Added existence operators: $exists, $isNull
  • โœ… Enhanced logical operators: improved $and, $or, $not support

Room-based Presence System

  • โœ… Added joinRoom() API returning scoped InstantRoom instances
  • โœ… Implemented room-specific presence operations (scoped to individual rooms)
  • โœ… Added topic-based pub/sub messaging with publishTopic() and subscribeTopic()
  • โœ… Complete room isolation - presence data separated between rooms
  • โœ… Backward compatible with existing direct room ID APIs

API Improvements

  • โœ… Added subscribeQuery() alias for reactive queries (matches React SDK)
  • โœ… Implemented queryOnce() for one-time query execution
  • โœ… Added getAuth() and subscribeAuth() convenience methods
  • โœ… Improved error handling and validation

๐Ÿงช Testing & Quality #

  • โœ… 150 total tests passing (up from 118 tests)
  • โœ… Added comprehensive test suite for all new features
  • โœ… Performance testing for large datasets and query caching
  • โœ… Room-based presence system testing with isolation validation

๐Ÿ› Bug Fixes & Performance Improvements #

  • โœ… Fixed transaction conversion for real-time sync - transactions now properly convert to tx-steps with actual data instead of sending 0 steps
  • โœ… Fixed duplicate entity issue during sync - implemented deduplication logic to prevent locally-created entities from being re-applied during refresh-ok
  • โœ… Fixed entity type resolution during sync - entities from server now properly stored with correct type (e.g., todos:id instead of unknown:id)
  • โœ… Fixed delete synchronization between instances - implemented differential sync to detect and apply deletions when entities are missing from server responses, including handling empty entity lists
  • โœ… Fixed presence reactions not appearing in peer instances - implemented proper refresh-presence message handling to convert reaction data to visible UI reactions
  • โœ… Fixed cursors, typing indicators, and avatars not working in peer instances - implemented complete presence data detection and routing in refresh-presence messages to handle all presence types
  • โœ… Fixed avatars page showing only 1 user instead of both users - preserved local user's presence when processing refresh-presence messages to match React SDK behavior
  • โœ… Fixed avatar presence data extraction and room ID consistency - corrected nested data structure extraction from refresh-presence messages and unified room key format usage
  • โœ… Fixed typing indicators showing 'Someone' instead of actual user names - updated typing page to set initial presence with userName and display actual user names in typing indicators
  • โœ… Added comprehensive hierarchical logging system - using logging package for better debugging and monitoring of sync operations
  • โœ… Enhanced sync engine with proper attribute UUID mapping - transactions now use correct InstantDB attribute UUIDs instead of attribute names

๐Ÿ“– Documentation #

  • โœ… Updated README with all new APIs and examples
  • โœ… Created ADVANCED_FEATURES.md comprehensive feature guide
  • โœ… Added MIGRATION_GUIDE.md for upgrading existing code
  • โœ… Updated example applications showcasing new room-based presence APIs

๐Ÿ“ฑ Example Applications Updated #

  • โœ… Cursors demo updated to use room-based presence API
  • โœ… Reactions demo updated with room-scoped reactions
  • โœ… Typing indicators demo updated with room-scoped typing
  • โœ… Avatars demo updated with room-scoped presence
  • โœ… Todos demo updated to showcase new tx namespace API

๐Ÿ”ง Breaking Changes #

None! This release is fully backward compatible. All existing APIs continue to work.

๐ŸŽฏ Migration Path #

  • Immediate: New projects can use new APIs from day one
  • Gradual: Existing projects can migrate incrementally at their own pace
  • Optional: Migration provides better performance and developer experience but is not required

0.1.2 #

๐Ÿ“š Documentation & Web Support #

  • Added web platform setup documentation with SQLite web worker configuration
  • Added documentation link to pub.dev pointing to https://instantdb-flutter-docs.pages.dev
  • Improved setup instructions to prevent web worker initialization errors

0.1.1 #

๐Ÿ”ง Fixes #

0.1.0 #

๐ŸŽ‰ Initial Release #

Core Features

  • โœ… Real-time synchronization with InstantDB backend
  • โœ… Offline-first local storage with SQLite triple store
  • โœ… Reactive UI updates using Signals
  • โœ… InstaQL query language support
  • โœ… Transaction system with optimistic updates
  • โœ… Authentication system integration
  • โœ… Schema validation and type safety

Flutter Integration

  • โœ… InstantProvider for dependency injection
  • โœ… InstantBuilder and InstantBuilderTyped reactive widgets
  • โœ… AuthBuilder for authentication state management
  • โœ… Watch widget for reactive UI updates
  • โœ… ConnectionStatusBuilder for network status

Presence System

  • โœ… Real-time cursor tracking
  • โœ… Typing indicators
  • โœ… Emoji reactions
  • โœ… User presence status
  • โœ… Room-based collaboration features

Developer Experience

  • โœ… Comprehensive example application
  • โœ… Full test coverage
  • โœ… TypeScript-style API design
  • โœ… Hot reload support
  • โœ… Debug tooling integration

0.0.1 #

  • Initial development release with basic InstantDB integration
7
likes
150
points
631
downloads

Publisher

unverified uploader

Weekly Downloads

A real-time, offline-first database client for Flutter with reactive bindings.

Repository (GitHub)
View/report issues
Contributing

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

crypto, dio, flutter, flutter_dotenv, json_annotation, logging, path, signals_flutter, sqflite, sqflite_common_ffi_web, uuid, web_socket_channel

More

Packages that depend on instantdb_flutter