formatTimestamp function
Formats a timestamp
Implementation
String formatTimestamp({
required int? timestamp,
bool showTime = true,
bool showDate = true,
}) {
if (timestamp != null) {
/// Format timestamp
final DateTime formattedTimestamp =
DateTime.fromMillisecondsSinceEpoch(timestamp);
final String formattedDate =
DateFormat('d MMM, yy').format(formattedTimestamp);
final String formattedTime = DateFormat('jm').format(formattedTimestamp);
return '${showDate ? formattedDate : ''} ${showTime ? 'at $formattedTime' : ''}';
}
return '';
}