搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目