๐Stream data
Stream provides you a sequence of data. It can become memory leaks, if you don't dispose them correctly.
Usage
class TimerViewModel extends PulseXStreamViewModel<String> { // specify stream data type
late Timer _timer;
final DateFormat formattedDate = DateFormat('h:mm:ss a'); // convert date format
void addDateTime() {
_timer = Timer.periodic(
const Duration(seconds: 1),
(timer) {
String currentTime = formattedDate.format(DateTime.now());
addValue(currentTime); // Pulse will automatically add data via sink
},
);
}
@override
void onDispose() {
_timer.cancel(); // cancel your timer or it'll probably make memory leak
}
}Last updated