fullFormat method

String fullFormat({
  1. String futureLabel = "in",
  2. String historyLabel = "ago",
  3. bool withYear = false,
  4. String dateLabel = "",
})

Implementation

String fullFormat({
  String futureLabel = "in",
  String historyLabel = "ago",
  bool withYear = false,
  String dateLabel = "",
}) {
  final flexiDate = this;
  final parts = <String>[];
  if (flexiDate.hasYear) {
    final dt = flexiDate.toDateTime();
    String formatted = timeago.format(dt, allowFromNow: true);
    if (historyLabel != "ago")
      formatted = formatted.replaceAll("ago", historyLabel);
    parts.add(formatted);
  }
  if (flexiDate.hasMonth && flexiDate.hasDay) {
    parts.add((dateLabel.isNotEmpty ? "$dateLabel " : "") +
        formatFlexiDate(flexiDate, withYear: withYear)!);
  }

  return parts.join(" - ");
}