I am looking for a way to calculate how much time has passed for each of the timestamps below. I have a basic way of using a stream, but can't figure out how to implement it. The counterStream.listen
shows an incremented value every second.
Widget _changeTimestamp(timestamp) {
var counterStream =
Stream<int>.periodic(Duration(seconds: 1), (x) => timestamp + x);
counterStream.listen(print);
}
return Scaffold(
body: ListView(
padding: const EdgeInsets.all(8.0),
children: <Widget>[
Container(
height: 50,
color: Colors.amber[600],
child: Center(child: _changeTimestamp(1562499809820)),
),
Container(
height: 50,
color: Colors.amber[500],
child: Center(child: _changeTimestamp(1562499766191)),
),
],
)
);