instantdb_flutter 0.2.5
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:
- App queries for
{'conversations': {}}
- Server returns datalog with conversation entities
- Entities lack __type field, so they default to 'todos'
- Cache stores them under 'todos' key
- 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:
- Cache is checked synchronously BEFORE creating the query Signal
- Query results are initialized with cached data immediately
- Applications receive data without any race conditions
- 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:
- Datalog format is properly converted to collection format
- Converted data is immediately available to applications
- No data loss occurs during the conversion process
- 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()
andunlink()
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 scopedInstantRoom
instances - โ Implemented room-specific presence operations (scoped to individual rooms)
- โ
Added topic-based pub/sub messaging with
publishTopic()
andsubscribeTopic()
- โ 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()
andsubscribeAuth()
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 ofunknown: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 #
- Fixed incorrect GitHub repository links in pubspec.yaml and CONTRIBUTING.md
- Repository links now correctly point to https://github.com/pillowsoft/instantdb_flutter
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
andInstantBuilderTyped
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