Notification constructor

const Notification({
  1. @JsonKey(name: 'notificationid') required int id,
  2. @UnixTimestampConverter() required DateTime timestamp,
  3. @UnixTimestampConverter() @JsonKey(name: 'timestamp_read') DateTime? readAt,
  4. required NotificationType type,
  5. @JsonKey(name: 'info') int? context,
  6. @BoolConverter() @JsonKey(name: 'status') required bool read,
  7. @JsonKey(name: 'userid') required int userId,
})

A notification users receive.

Implementation

const factory Notification({
  /// The notification's unique identifier.
  @JsonKey(name: 'notificationid') required int id,

  /// The timestamp when the notification was sent.
  @UnixTimestampConverter() required DateTime timestamp,

  /// The timestamp when the notification was read.
  @UnixTimestampConverter() @JsonKey(name: 'timestamp_read') DateTime? readAt,

  /// The type of the notification.
  ///
  /// The message is displayed differently based on the type.
  required NotificationType type,

  /// Additional context for the notification.
  /// Interpretation depends on the [type].
  @JsonKey(name: 'info') int? context,

  /// `true` if the notification has been read.
  @BoolConverter() @JsonKey(name: 'status') required bool read,
  @JsonKey(name: 'userid') required int userId,
}) = _Notification;