Coded this.
List<DateTime> dates = [DateTime.now(), DateTime.utc(1998, 2, 11)];
Scaffold(
body: Center(
child: ListView.builder(
itemCount: dates.length,
itemBuilder: (context, index) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text('${DateFormat.yMd().add_jm().format(dates[index])}'),
),
if(index < dates.length - 1)
Padding(
padding: const EdgeInsets.all(8.0),
child: Text('${dates[index].difference(dates[index + 1]).inHours} hours ${dates[index].difference(dates[index + 1]).inMinutes.remainder(60)} minute'),
)
],
);
},
),
),
);
Note: Refer to this document for details on DateTime formatting.
https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…