take-->What role does it play (flutter and Dart)
class Ticker {
Stream<int> tick({int ticks}) => Stream.periodic(Duration(seconds: 1), (x) {
return ticks - x - 1;
}).take(ticks);
}
So simply, it just takes items as count of you pass(ticks parameter) from a stream.
// This stream is responsible to do a task for each second
Stream.periodic(Duration(seconds: 1), (x) {
return ticks - x - 1;
})
// With take, stream does it's job only `ticks` times
Stream.periodic(Duration(seconds: 1), (x) {
return ticks - x - 1;
}).take(ticks);