selfprivacy.org.app/lib/logic/models/message.dart

23 lines
457 B
Dart
Raw Normal View History

2021-01-14 21:48:05 +00:00
import 'package:intl/intl.dart';
2022-02-16 07:28:29 +00:00
final formatter = new DateFormat('hh:mm');
2021-01-14 21:48:05 +00:00
class Message {
2021-01-18 10:21:55 +00:00
Message({this.text, this.type = MessageType.normal}) : time = DateTime.now();
2021-01-14 21:48:05 +00:00
2021-03-15 15:39:44 +00:00
final String? text;
2021-01-14 21:48:05 +00:00
final DateTime time;
2021-01-18 10:21:55 +00:00
final MessageType type;
2022-02-16 07:28:29 +00:00
String get timeString => formatter.format(time);
2021-01-18 10:21:55 +00:00
2021-03-15 15:39:44 +00:00
static Message warn({String? text}) => Message(
2021-01-18 10:21:55 +00:00
text: text,
type: MessageType.warning,
);
}
enum MessageType {
normal,
warning,
2021-01-14 21:48:05 +00:00
}