搜索插件、代码仓与 APP 分类

插件详情v1.0.2

livestream

LiveStream 是一个简单的类,可让您应用的不同模块之间轻松通信。

近 30 天下载
29
喜欢数
29
Pub 分数
40

安装插件

flutter pub add livestream

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Livestream 是一个轻量级的 Flutter 包,旨在简化应用程序不同部分之间的通信。它提供了一种简单的方式来广播和监听事件,非常适合用于状态管理和模块间通信,而无需使用复杂的大框架。该包基于简单的发布-订阅模式,可在小部件、服务或屏幕之间实现高效的数据流。只需最少的设置且无外部依赖,Livestream 能够增强 Flutter 应用的模块化和响应性。

适合场景

  • 实时事件广播
  • 跨小部件通信
  • 简化状态更新
  • 解耦应用模块
  • 跨屏幕处理用户操作
  • 简化插件交互

主要特点

  • 简单的发布-订阅模型
  • 最小化样板代码
  • 无外部依赖
  • 轻量且快速
  • 与现有代码的轻松集成
  • 支持类型化事件

适合对象

  • 中小型Flutter应用
  • 寻求轻量级状态管理的开发者
  • 避免复杂依赖注入的团队
  • 需要快速事件驱动通信的应用程序
  • 快速原型用户界面更新
  • 优先考虑简单性而非可扩展性的项目

使用建议

  • 不适合大规模状态管理
  • 仅限基本事件处理
  • 无内置持久化或恢复功能
  • 最适合临时或瞬时数据
  • 在长时间运行的应用程序中可能需要手动清理
  • 不适合复杂的数据同步

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

LiveStream - Dart

Pub Github Followers GitHub stars GitHub forks GitHub watchers Twitter Follow

LiveStream is a data holder class which can observe change of data in real-time and emit values too. Here's emitter subscriber pattern. It's developed in pure Dart.

⚡️ Getting Started

Add Dependency

Add below dependency in pubspec.yaml.

dependencies:
  livestream: ^1.0.2
Initialize LiveStream Instance

You can create instance as below.

  LiveStream liveStream = new LiveStream();
Subscribe to Stream / Add Observer

LiveStream event will be dispatched when data is changed. See below code to add observer / subscriber.

    liveStream.on("chat-message", (message) {
      print("Message Received: $message");
    });

Whenever data is emitted to chat-message channel/stream above block will be executed.

Emitting Events or Broadcasting

The main idea behind LiveStream is that you can send and receive any events you want, with any data you want. Any objects that can be encoded as JSON will do, and binary data is supported too. See code below.

  void send() {
      String message = "Hi there!";
      liveStream.emit("chat-message", message);
  }

🚀 Sample Usage

Sample code is available in /example directory.

🤝 Contribute

If you want to contribute to this library, you're always welcome! See Contributing Guidelines.

✉️ Contact

If you need any help, you can connect with me.

Visit:- shreyaspatil.dev

📃 License

MIT License

Copyright (c) 2020 Shreyas Patil

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。