meeting_place_drift_repository 0.0.1-dev.53
meeting_place_drift_repository: ^0.0.1-dev.53 copied to clipboard
The Meeting Place Drift Repository is a package that uses Drift to persist and manage channels, connection offers, groups, anc chat history in local device storage.
Affinidi Meeting Place - Drift Repository SDK for Dart #

The Affinidi Meeting Place - Drift Repository SDK is a package that implements the Drift database to persist and manage channels, connection offers, groups, and chat history in the device's local storage.
Key Features #
-
Manage channels
- Create a channel
- Retrieve a channel via either your DID or the other party DID
- Retrieve a channel via the other party DID
- Retrieve a channel via an offerLink
- Update a channel
- Delete a channel
-
Manage connections
- Create a connection offer
- Retrieve a connection via an offerLink
- Retrieve a connection via a permanent channel DID
- Retrieve a connection via a group DID
- Retrieve all connection offers
- Update a connection offer
- Delete a connection offer
-
Manage groups
- Create a group
- Retrieve a group by id
- Retrieve a group by offerLink
- Update a group
- Delete a group
-
Manage chat history
- Create a message
- Retrieve all messages associated to a chatId
- Retrieve a message within a chat by Id
- Update a message
Requirements #
- Dart SDK version ^3.9.2
Installation #
Run:
dart pub add meeting_place_drift_repository
or manually add the package to your pubspec.yaml file:
dependencies:
meeting_place_drift_repository: ^<version_number>
and then run the command below to install the package:
dart pub get
For more information, visit the pub.dev install page of the package.
Regenerate Database Classes #
The package uses drift code generation. To regenerate database classes, run:
dart run build_runner build --delete-conflicting-outputs
Schema Migrations #
This package uses Drift schema snapshots to verify that each migration produces the exact schema the Dart model expects.
Files #
| Path | Description |
|---|---|
drift_schemas/drift_schema_vN.json |
JSON snapshot of the database schema at version N. Committed to source control. |
test/utils/schema_versions.dart/ |
Dart helpers generated from the snapshots, used by SchemaVerifier in migration tests. Do not edit by hand. |
test/utils/schema_versions.dart/ contains three generated files:
schema.dart— exportsGeneratedHelper, the entry point forSchemaVerifier.schema_vN.dart— a minimal generated database class mirroring the table structure at version N (no app logic).SchemaVerifieruses these to create an in-memory database at any historical version, run the actualonUpgradecallback against it, then diff the result against the snapshot.
When to update #
Bump schemaVersion in ChatItemsDatabase whenever the table structure changes,
then run the two commands below from the package root.
1. Dump the new snapshot:
dart run drift_dev schema dump \
lib/src/repositories/chat_items_repository/chat_items_database.dart \
drift_schemas/drift_schema_v<new_version>.json
2. Regenerate the test helpers:
dart run drift_dev schema generate \
drift_schemas/ \
test/utils/schema_versions.dart/
Commit both the new drift_schema_vN.json and the regenerated
test/utils/schema_versions.dart/ files. Then add a migration test block
in test/chat_items_migration_test.dart for the new version.
Canary test #
test/chat_items_migration_test.dart contains a canary test that verifies
GeneratedHelper.versions includes the current schemaVersion. If the two
commands above are not run after bumping the version, CI will fail immediately
with a message like:
Expected: contains <3>
Actual: [1, 2]
This catches the missing snapshot steps before the migration tests even run.
Database Encryption (Required) #
package:sqlite3 v3 no longer ships SQLCipher. Projects using this package
must configure sqlite3 to use
SQLite3MultipleCiphers
by adding the following to their pubspec.yaml:
hooks:
user_defines:
sqlite3:
source: sqlite3mc
Without this configuration, database encryption is not available and the SDK
will throw an UnsupportedError at runtime.
New databases #
New databases are encrypted with the sqlite3mc default cipher. No additional
configuration is needed beyond PRAGMA key.
Existing SQLCipher databases #
Databases created with the previous SQLCipher-based build are opened
automatically in compatibility mode (PRAGMA cipher = 'sqlcipher' /
PRAGMA legacy = 4). This is handled transparently — the SDK tries the
default cipher first and falls back to SQLCipher compatibility mode when
needed.
Note: Legacy mode is used only for reading existing SQLCipher databases. It is not recommended for new databases.
See the sqlite3 v3 upgrade guide for more details.