{"id":25713950,"url":"https://github.com/pocketsync/pocketsync_flutter","last_synced_at":"2025-10-14T07:40:18.554Z","repository":{"id":279301786,"uuid":"938240103","full_name":"pocketsync/pocketsync_flutter","owner":"pocketsync","description":"Flutter SDK for pocketsync.dev","archived":false,"fork":false,"pushed_at":"2025-05-09T08:12:16.000Z","size":462,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-05-09T08:38:47.988Z","etag":null,"topics":["dart","data-synchronization","flutter","sqlite"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/pocketsync_flutter","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pocketsync.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-24T16:34:31.000Z","updated_at":"2025-05-09T08:12:19.000Z","dependencies_parsed_at":"2025-05-01T20:21:15.887Z","dependency_job_id":"85135c63-68cb-4879-9d01-c0f59695e5f1","html_url":"https://github.com/pocketsync/pocketsync_flutter","commit_stats":null,"previous_names":["pocketsync/pocketsync_flutter"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pocketsync/pocketsync_flutter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pocketsync%2Fpocketsync_flutter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pocketsync%2Fpocketsync_flutter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pocketsync%2Fpocketsync_flutter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pocketsync%2Fpocketsync_flutter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pocketsync","download_url":"https://codeload.github.com/pocketsync/pocketsync_flutter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pocketsync%2Fpocketsync_flutter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018215,"owners_count":26086307,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dart","data-synchronization","flutter","sqlite"],"created_at":"2025-02-25T12:27:37.859Z","updated_at":"2025-10-14T07:40:18.549Z","avatar_url":"https://github.com/pocketsync.png","language":"Dart","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/pocketsync/pocketsync_flutter/refs/heads/main/banner.png\" alt=\"PocketSync Logo\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://pocketsync.dev\"\u003eWebsite\u003c/a\u003e ·\n  \u003ca href=\"https://docs.pocketsync.dev\"\u003eDocumentation\u003c/a\u003e ·\n  \u003ca href=\"https://github.com/pocketsync/pocketsync_flutter/issues\"\u003eReport Bug\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\nPocketSync enables seamless data synchronization across devices without managing your own backend infrastructure. It works with SQLite databases and handles all the complexities of data synchronization for you.\n\n\u003e **Note:** PocketSync is currently in alpha. The system is under active development and should not be considered reliable for production use. We are still yet to test it in production like conditions.\n\n## Features\n\n- **Offline-first architecture**: Continue working with your data even when offline\n- **Automatic synchronization**: Changes are automatically synchronized when connectivity is restored\n- **Conflict resolution**: Multiple built-in strategies for handling conflicts\n- **Optimized change tracking**: Efficiently tracks and batches changes to minimize network usage\n- **SQLite integration**: Built on top of SQLite for reliable local data storage\n- **Customizable**: Flexible configuration options to suit your specific needs\n\n## Installation\n\n```yaml\ndependencies:\n  pocketsync_flutter: latest\n```\n\nThen run:\n\n```bash\nflutter pub get\n```\n\n## Quick start\n\nYou'll need to create a PocketSync project in the [PocketSync dashboard](https://pocketsync.dev) and get your project ID, auth token, and server URL.\n\n### 1. Initialize PocketSync\n\n```dart\nimport 'package:pocketsync_flutter/pocketsync_flutter.dart';\nimport 'package:path/path.dart';\nimport 'package:sqflite/sqflite.dart';\n\nFuture\u003cvoid\u003e initPocketSync() async {\n  // Get the database path\n  String dbPath = join(await getDatabasesPath(), 'my_app_database.db');\n  \n  // Initialize PocketSync\n  await PocketSync.initialize(\n    options: PocketSyncOptions(\n      projectId: 'YOUR_PROJECT_ID',\n      authToken: 'YOUR_AUTH_TOKEN',\n      serverUrl: 'https://api.pocketsync.dev',\n      // Optional configurations\n      conflictResolutionStrategy: ConflictResolutionStrategy.lastWriteWins,\n      verbose: true,\n    ),\n    databaseOptions: DatabaseOptions(\n      dbPath: dbPath,\n      version: 1,\n      schema: DatabaseSchema(\n        tables: [\n          TableSchema(\n            name: 'todos',\n            columns: [\n              TableColumn.primaryKey(name: 'id', type: ColumnType.INTEGER),\n              TableColumn.text(name: 'title'),\n              TableColumn.boolean(name: 'isCompleted'),\n            ],\n          ),\n        ],\n      ),\n    ),\n  );\n\n  // Authenticate\n  PocketSync.instance.setUserId('my-user-id');\n  \n  // Start the sync engine\n  await PocketSync.instance.start();\n}\n```\n\n### 2. Use the PocketSync database\n\n```dart\n// Get a reference to the database\nfinal db = PocketSync.instance.database;\n\n// Insert data\nawait db.insert('todos', {\n  'title': 'Buy groceries',\n  'isCompleted': 0,\n});\n\n// Query data\nList\u003cMap\u003cString, dynamic\u003e\u003e todos = await db.query('todos');\n\n// Update data\nawait db.update(\n  'todos',\n  {'isCompleted': 1},\n  where: 'id = ?',\n  whereArgs: [1],\n);\n\n// Delete data\nawait db.delete('todos', where: 'id = ?', whereArgs: [1]);\n\n// Watch database changes\nfinal stream = db.watch('SELECT * FROM todos');\nstream.listen((event) {\n  print(event);\n});\n```\n\nRead more: [PocketSync Database](https://docs.pocketsync.dev/database)\n\n### 3. Manual sync control\n\n```dart\n// Manually trigger sync\nawait PocketSync.instance.scheduleSync();\n\n// Pause synchronization\nawait PocketSync.instance.stop();\n\n// Resume synchronization\nawait PocketSync.instance.start();\n```\n\n### 4. Conflict resolution\n\nPocketSync provides several strategies for resolving conflicts:\n\n- **Last Write Wins**: The most recent change based on timestamp wins (default)\n- **Server Wins**: Server changes always take precedence\n- **Client Wins**: Local changes always take precedence\n- **Custom**: Provide your own conflict resolution logic\n\n```dart\n// Using a custom conflict resolver\nawait PocketSync.initialize(\n  options: PocketSyncOptions(\n    // ... other options\n    conflictResolutionStrategy: ConflictResolutionStrategy.custom,\n    customResolver: (localChange, remoteChange) async {\n      // Your custom logic to decide which change wins\n      return localChange.timestamp \u003e remoteChange.timestamp\n          ? localChange\n          : remoteChange;\n    },\n  ),\n  // ... database options\n);\n```\n\n### 5. Advanced usage\n\n#### User authentication\n\nSet the user ID:\n\n```dart\nPocketSync.instance.setUserId('user123');\n```\n\nNote that this is required for sync to actually work. On the server side, the user ID is used to identify the user and their data.\n\n#### Reset sync state\n\nClear all sync tracking data (use with caution):\n\n```dart\nawait PocketSync.instance.reset();\n```\n\n\u003e **Note:** Call `PocketSync.instance.reset()` before calling `PocketSync.instance.start()` to reset the sync engine (for existing apps. Be cautious when using this method as it will clear all change tracking data). It runs once per plugin version (the goal is to provide a smooth transition for people that were using the sdk prior to version 0.3.0)\n\n### Dispose Resources\n\nClean up resources when the app is closing:\n\n```dart\nawait PocketSync.instance.dispose();\n```\n\n## Migration\n\n### From 0.4.2 to 0.5.0\n\n- PocketSync now uses the new schema system to define your database schema. This change is interesting because it enables a set of features that were not possible before. Our your end, it helps you to define your database schema in a more type-safe way.\n\n### From 0.2.0 to 0.3.0\n\n- PocketSync now uses SQLite FFI to fix issues with JSON_OBJECT function not being available on some Android devices\n- The implementation uses sqflite_common_ffi and sqlite3_flutter_libs packages to provide a more recent version of SQLite with JSON function support\n- A SqliteFfiHelper class was created to initialize the FFI implementation before database operations\n- Call `PocketSync.instance.reset()` before calling `PocketSync.instance.start()` to reset the sync engine.\n\n## Best practices\n\n1. **Initialize early**: Initialize PocketSync during app startup\n2. **Handle conflicts**: Choose an appropriate conflict resolution strategy for your app\n3. **Batch operations**: Group related database operations to optimize sync performance\n4. **User authentication**: Set the user ID when the user logs in (sync will not work without a user ID)\n\n## Support\n\nIf you have any questions or need help, please open an issue on the [GitHub repository](https://github.com/pocketsync/pocketsync_flutter). \n\nIf you need to talk to the PocketSync team, please reach out to [hello@pocketsync.dev](mailto:hello@pocketsync.dev).\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpocketsync%2Fpocketsync_flutter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpocketsync%2Fpocketsync_flutter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpocketsync%2Fpocketsync_flutter/lists"}