visitText function

String visitText(
  1. dynamic l10n,
  2. Visit visit,
  3. DateTime now,
  4. String locale, {
  5. bool named = false,
})

One visit as the status line lists it: 14:32 (3 min), or the time alone while it goes on; named, what came first.

Implementation

String visitText(
  AppLocalizations l10n,
  Visit visit,
  DateTime now,
  String locale, {
  bool named = false,
}) {
  final time = formatLastSeen(visit.arrived, now, locale);
  final stayed = visit.stayed;
  final text = stayed == null
      ? time
      : l10n.detectionVisitStay(time, stayMinutes(stayed));
  final what = visit.what;
  if (!named || what == null) {
    return text;
  }
  return '${watchedLabel(<String>[what], locale.split(RegExp('[_-]')).first)} $text';
}