time property
String
get
time
Implementation
String get time {
final dateFormatter = DateFormat('yyyy-MM-ddTHH:mm:ss.SSSZZZZZ');
if (created != null) {
final date = dateFormatter.parse(created!);
final timeDifference = DateTime.now().difference(date);
final timeSince = timeDifference.inSeconds;
if (timeSince < 60) {
return 'now';
} else if (timeSince < 3600) {
return '${timeSince ~/ 60} minutes ago';
} else if (timeSince < 86400) {
return '${timeSince ~/ 3600} hours ago';
} else {
return '${timeSince ~/ 86400} days ago';
}
}
return 'now';
}