FLUTTER ECOSYSTEM

arnold-parge/stream_mixin

任意のクラスオブジェクトにストリーム動作を追加するためのシンプルなDartミックスイン

stream_mixin のプロジェクト画像
Stars
7
Forks
0
最終プッシュ(UTC)
2021/12/20
プロジェクト状態
公開中
arnold-parge GitHub avatar
GITHUB User

arnold-parge ↗

言語Dart

技術トピック

このリポジトリが公開するパッケージ

使用している依存関係

依存関係一覧 3 件
  • flutter{"sdk":"flutter"}
  • flutter_lints開発用^1.0.4
  • flutter_test開発用{"sdk":"flutter"}

元の README

以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。

README を開く / 閉じる

stream_mixin

State management using stream to avoid use of flutter's State/setState/StatefulWidget, boosting the performance and code separation.

Breaking change in 2.0.0 and 3.0.0. Check the changelog.

The Intention

The intention for this package is to use stream instead of flutter's state for streaming data from the controller/adapter/service class to the widgets, which results in better performance and cleaner code.

Basic example

A basic example of a counter service that increments the count and streams the count to the widget

class Counter with StreamMixin<int> {
  increment() {
    update((lastUpdate ?? 0) + 1);
  }
}

/// You can either create a global instance of Counter or create a
/// singleton (recommented) like class by adding the following in Counter class
/// ```dart
///   Counter._();
///   static Counter instance = Counter._();
/// ```
final counter = Counter();

anywhereInTheApp() {
  counter.increment();
}

Widget someWidget() {
  return StreamBuilder<int>(
    stream: counter.onChange,
    builder: (cxt, snap) => Text((snap.data ?? 0).toString()),
  );
}

Contribute ❤️

There are couple of ways in which you can contribute.

  • Propose any feature, enhancement
  • Report a bug
  • Fix a bug
  • Participate in a discussion and help in decision making
  • Write and improve some documentation. Documentation is super critical and - its importance cannot be overstated!
  • Send in a Pull Request 🙂