stream_mixin
स्टेट मैनेजमेंट के लिए स्ट्रीम का उपयोग करके फ्लटर के State/setState/StatefulWidget के उपयोग से बचें, प्रदर्शन और कोड विभाजन में वृद्धि करें।
किसी भी क्लास ऑब्जेक्ट में स्ट्रीम व्यवहार जोड़ने के लिए एक सरल डार्ट मिक्सिन
{"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.