String convertToAgo(String input, { bool short = false }) { DateTime time = DateTime.parse(input); Duration diff = DateTime.now().difference(time); if(diff.inDays >= 1){ return '${diff.inDays} day${diff.inDays == 1 ? "" : "s"} ${short ? '': 'ago'}'; } if(diff.inHours >= 1){ return '${diff.inHours} hour${diff.inHours == 1 ? "" : "s"} ${short ? '' : 'ago'}'; } if(diff.inMinutes >= 1){ return '${diff.inMinutes} ${short ? 'min' : 'minute'}${diff.inMinutes == 1 ? "" : "s"} ${short ? '' : 'ago'}'; } if (diff.inSeconds >= 1){ return '${diff.inSeconds} ${short ? '' : 'second'}${diff.inSeconds == 1 ? "" : "s"} ${short ? '' : 'ago'}'; } return 'just now'; }