v3.0.4
stream_mixin
Flutter의 State/setState/StatefulWidget 사용을 피하기 위해 스트림을 사용한 상태 관리로 성능 향상과 코드 분리를 달성합니다.
6좋아요 81630일 다운로드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.