setNotificationField method

DynamicDocumentModel setNotificationField({
  1. required String title,
  2. required String text,
  3. required DateTime time,
  4. String timeKey = MetaConst.pushTime,
  5. String titleKey = MetaConst.pushName,
  6. String textKey = MetaConst.pushText,
})

Create a field for notification.

title is the title of the push notification, text is the content of the push notification, and time is the date and time the push notification was sent.

timeKey, titleKey, and textKey specify the respective keys.

Implementation

DynamicDocumentModel setNotificationField({
  required String title,
  required String text,
  required DateTime time,
  String timeKey = MetaConst.pushTime,
  String titleKey = MetaConst.pushName,
  String textKey = MetaConst.pushText,
}) {
  assert(title.isNotEmpty, "The title is empty.");
  assert(text.isNotEmpty, "The text is empty.");
  assert(timeKey.isNotEmpty, "The time key is empty.");
  assert(titleKey.isNotEmpty, "The title key is empty.");
  assert(textKey.isNotEmpty, "The text key is empty.");
  this[timeKey] = time.millisecondsSinceEpoch;
  this[titleKey] = title;
  this[textKey] = text;
  return this;
}