Solian/lib/widgets/relative_date.dart

29 lines
597 B
Dart
Raw Normal View History

2024-09-23 14:43:02 +00:00
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:timeago/timeago.dart';
class RelativeDate extends StatelessWidget {
final DateTime date;
2024-10-16 14:32:44 +00:00
final TextStyle? style;
2024-09-23 14:43:02 +00:00
final bool isFull;
2024-10-16 14:32:44 +00:00
const RelativeDate(this.date, {super.key, this.style, this.isFull = false});
2024-09-23 14:43:02 +00:00
@override
Widget build(BuildContext context) {
if (isFull) {
2024-10-16 14:32:44 +00:00
return Text(
DateFormat('y/M/d HH:mm').format(date),
style: style,
);
2024-09-23 14:43:02 +00:00
}
return Text(
format(
date,
locale: 'en_short',
),
2024-10-16 14:32:44 +00:00
style: style,
2024-09-23 14:43:02 +00:00
);
}
}