lastActivityLabel property

String get lastActivityLabel

Last activity label: "Active now", "2h ago", "Yesterday"

Implementation

String get lastActivityLabel {
  if (lastMessageAt == null) return 'No messages';

  final now = DateTime.now();
  final diff = now.difference(lastMessageAt!);

  if (diff.inMinutes < 5) return 'Active now';
  if (diff.inHours < 24) return '${diff.inHours}h ago';
  if (diff.inDays == 1) return 'Yesterday';

  return DateFormat('MMM d').format(lastMessageAt!);
}