v3.0.4
stream_mixin
使用流進行狀態管理,以避免使用 Flutter 的 State/setState/StatefulWidget,提升效能並實現程式碼分離。
6喜歡 816近 30 天下載160Pub 分數
AndroidiOSWebmacOSWindowsLinux
一個簡單的 Dart 混入,用於向任何類別物件新增串流行為
{"sdk":"flutter"}^1.0.4{"sdk":"flutter"}以下為英文專案原文快照,最新內容請造訪 GitHub。
State management using stream to avoid use of flutter's State/setState/StatefulWidget, boosting the performance and code separation.
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.
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()),
);
}
There are couple of ways in which you can contribute.