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

23 lines
455 B
Dart
Raw Normal View History

2021-01-14 21:48:05 +00:00
import 'package:intl/intl.dart';
final formater = new DateFormat('hh:mm');
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;
2021-01-14 21:48:05 +00:00
String get timeString => formater.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
}