搜尋套件、儲存庫與 APP 分類

套件詳情v2.13.2

realtime_client

監聽 PostgreSQL 資料庫和透過 WebSocket 的變更。此功能用於與 Supabase 即時伺服器搭配使用。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
133萬
喜歡數
76
Pub 分數
140

安裝套件

flutter pub add realtime_client

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

realtime_client 套件讓 Flutter 應用程式能透過 WebSocket 從 PostgreSQL 資料庫接收即時更新,特別設計用於與 Supabase Realtime 伺服器整合。它允許應用程式即時監聽資料庫變更,例如插入、更新和刪除,確保資料在各個客戶端之間保持同步,無需手動輪詢。非常適合需要即時資料更新的協作應用、聊天系統或儀表板。此套件支援所有主要平台,包括行動裝置、網頁和桌面,適用於跨平台的即時體驗。

適用情境

  • 即時聊天應用
  • 即時儀表板更新
  • 協作編輯工具
  • 即時通知系統
  • 資料庫變更監控

主要特色

  • 基於 WebSocket 的即時更新
  • Supabase 實時伺服器整合
  • 跨平台支援
  • 事件驅動的數據監聽
  • 自動重連處理

適合對象

  • 開發即時功能的開發者
  • 需要即時資料同步的應用程式
  • 基於 Supabase 的專案
  • 多用戶互動式應用
  • 全端Flutter開發人員

使用建議

  • 需要一個啟用了即時功能的 Supabase 項目
  • WebSocket通訊需要網路連接
  • 高頻率事件可能帶來的效能影響
  • 需要身份驗證才能存取安全通訊通道
  • 受限於 Supabase 的即時基礎設施

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。


Supabase Logo

Supabase Flutter

Flutter client library for Supabase.

Guides · Reference Docs · Migration Guides

Build Package License: MIT

Run locally

This repo is a monorepo powered by Melos containing supabase_flutter and its sub-libraries. All packages are located in the packages directory.

To install on a locally developed app:

  • Clone this repo
  • Install Melos globally if you haven't already: dart pub global activate melos
  • Run melos bootstrap or melos bs at the root of the cloned directory to install dependencies
  • Add the target package to your pubspec.yaml file specifying the path.
    supabase_flutter:
      path: <your-path-to-the-local-supabase-flutter-repo>/packages/supabase_flutter
    

Testing your app

The helpers the test suites of these packages run on are published in package:supabase_test, so your tests can build on the same primitives: mock HTTP clients, JWT builders, auth session fixtures and realtime frames. Add the package as a dev dependency:

dev_dependencies:
  supabase_test: ^0.1.0

Then stub the endpoints the code under test talks to and run it against a real SupabaseClient, with no running stack required:

final httpClient = MockSupabaseHttpClient()
  ..stubTable('todos', rows: [
    {'id': 1, 'task': 'Ship it', 'status': false},
  ]);
final supabase = testSupabaseClient(httpClient: httpClient);
addTearDown(supabase.dispose);

final todos = await supabase.from('todos').select();
expect(todos, hasLength(1));

See the supabase_test README for the full guide: stubbing database, rpc, edge function and auth endpoints, asserting on recorded requests, running tests as a signed-in user, and wiring Supabase.initialize in Flutter widget tests.

Testing this repo

The tests for the packages postgrest, supabase_auth, supabase_realtime and supabase_storage run against a local Supabase stack. To run these tests locally you need docker and the Supabase CLI installed.

The single configuration for the stack lives in the supabase directory at the repository root. Start it with:

supabase start

Run the Dart tests within the package directory in packages/<package> with the following command. The -j 1 flag runs the tests not concurrently, which works better since the tests run against the same services.

dart test -j 1

To stop the stack run the following command from the repository root:

supabase stop

Contributing

  • Fork the repo on GitHub
  • Clone the project to your own machine
  • Commit changes to your own branch
  • Push your work back up to your fork
  • Submit a Pull request so that we can review your changes and merge

License

This repo is licensed under MIT.

Resources

所屬分類

依賴

依賴清單 6 項

原始碼儲存庫

使用此套件的專案